I was wondering if this
$c = mysql_num_rows(mysql_query("select * from action_6_weekly where code='$code'"));
is considered valid PHP?
Or do I need to do the following?
$r = mysql_query("select * from action_6_weekly where code='$code'");
$c = mysql_num_rows($r);
this is what i am actually doing:
if($entry == '9')
$c = mysql_num_rows(mysql_query("select * from action_6_5pts where code='$code'")) or die ('MYSQL ERROR: '.mysql_error().' in '.__FILE__.' on '.__LINE__.'.');
elseif($entry == 'a')
$c = mysql_num_rows(mysql_query("select * from action_6_10pts where code='$code'")) or die ('MYSQL ERROR: '.mysql_error().' in '.__FILE__.' on '.__LINE__.'.');
else
$c = mysql_num_rows(mysql_query("select * from action_6_weekly where code='$code'")) or die ('MYSQL ERROR: '.mysql_error().' in '.__FILE__.' on '.__LINE__.'.');
if($c > 0)
$waiting_for_reply = false;
It is generally better to do it on separate lines and assign it a variable.
This way you can work with the result easier. But to get a count of rows, if that is all you are looking for, this would be better and more efficient:
Where the id is the unique identifier field to count.
EDIT:
Given that you do not care how many rows there are, just that it exists: