Forum Moderators: coopster
I usually creat the query on one line and then put my call to mysql_query on a seperate line. This will make a big difference in debugging.
$mysearchcriteria = 'Wild About the Zoo - 9:00';
$q = "SELECT SUM(IF(Session1_9 = '" . $mysearchcriteria . "',1,0)) AS total FROM Students";
$spaceq = mysql_query($q);
then if you are debugging this you can always set it up like so to see if your query is being properly constructed
$mysearchcriteria = 'Wild About the Zoo - 9:00';
$q = "SELECT SUM(IF(Session1_9 = '" . $mysearchcriteria . "',1,0)) AS total FROM Students";
echo $q;
die();
$spaceq = mysql_query($q);
if you didn't want to execute it, you should also add or die statements to queries while developing, or you can create an error handler but the dies are easier
$spaceq = mysql_query($q) or die ('select query died: ' . mysql_error());
$row = mysql_fetch_object($query);
$class=$row['EventName'];
$spaceq = mysql_query("SELECT SUM(IF(Session1_9 = '".$class."',1,0)) AS total FROM Students");
it doesnt seem to be readin the $class string right as if i type in the amount it does it right but if i echo row['eventname'] its works
[php.net...]