Page 1 of 1

Re: help with script

Posted: Wed Sep 19, 2012 11:08 pm
by NigelRen
You should always check that a query has executed successfully before you try and use the return value. So depending on what your $db database type is, you may need to check if $db->query($sql) returns false as this may indicate a problem with the query.

Note that this depends entirely on what $db is and you will have to work it out from any information you have, but the main idea is:
Execute some SQL
Did this fail?
Report error and exit
// Must have worked so...
foreach Result Set
Do something with each row