right, my program is whining about this code... PHP: include 'db-info.php'; $select=="1"; $query = "SELECT * from UKAB_Candidate WHERE no='$select'"; while($a_row = mysql_fetch_object($query)) { $FORENAME == $a_row->forename; $SURNAME == $a_row->surname; $DOB == $a_row->dob; $CAND_NO == $a_row->cand_no; $CENT_NO == $a_row->cent_no; } the error reports this line... PHP: while($a_row = mysql_fetch_object($query)) to be causing the problems! but i cannot work out why! any help is appreciated, thnks! jafefr
Not to go after the obvious, but there's a mysql_connect() and a mysql_select_db() in there somewhere before you blast away with mysql_fetch_object(), right? What's the error message you get? It's usually kinda helpful.
yes there is sorry, forgot to give you there error it is... Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/usr/abunting/public_html/CWK/candidate.php on line 27
that means mysql_connect() failed usually, try echoing mysql_error() right after you connect, and if you have one of those @ signs in front of mysql_connect() remove it, and more info should appear magically. This is an excellent example of a common mistake in PHP programming, assuming that a function call succeeded. In fact, it's number 12.
PHP: include 'db-info.php'; $select=="1"; $query = "SELECT * from UKAB_Candidate WHERE no='$select'"; while($a_row = mysql_fetch_object($query)) { try PHP: $query = "SELECT * from UKAB_Candidate WHERE no='$select'"; $result = mysql_query(mysql_query); while($a_row = mysql_fetch_object($result)) { 1) you need to get the query before getting the objects with mysql_query($query). 2) did you mean to have $DOB == $a_row->dob; instead of $DOB = $a_row->dob; single '=' insead of 2