Jump to content

Query Die


aeroswat

Recommended Posts

For some reason my code is working but it's still printing out Error 1...

				$qry1 = "SELECT isReading, isPhysical FROM tblStudents WHERE isReading='1' AND isPhysical='0' AND SchoolSystem='" . $res0['systemName'] . "'";
			$qry2 = "SELECT isReading, isPhysical FROM tblStudents WHERE isReading='0' AND isPhysical='1' AND SchoolSystem='" . $res0['systemName'] . "'";
			$qry3 = "SELECT isReading, isPhysical FROM tblStudents WHERE isReading='1' AND isPhysical='1' AND SchoolSystem='" . $res0['systemName'] . "'";
			$result1 = mysql_query($qry1) or die("Error 1");
			$result2 = mysql_query($qry2) or die("Error 2");
			$result3 = mysql_query($qry3) or die("Error 3");	

 

Any ideas why?

Link to comment
https://forums.phpfreaks.com/topic/184452-query-die/
Share on other sites

Instead of using die let's use trigger_error with mysql_error  to tell us what the issue is:

 

            $qry1 = "SELECT isReading, isPhysical FROM tblStudents WHERE isReading='1' AND isPhysical='0' AND SchoolSystem='" . $res0['systemName'] . "'";
            $qry2 = "SELECT isReading, isPhysical FROM tblStudents WHERE isReading='0' AND isPhysical='1' AND SchoolSystem='" . $res0['systemName'] . "'";
            $qry3 = "SELECT isReading, isPhysical FROM tblStudents WHERE isReading='1' AND isPhysical='1' AND SchoolSystem='" . $res0['systemName'] . "'";
            $result1 = mysql_query($qry1) or trigger_error("Error 1: " . mysql_error());
            $result2 = mysql_query($qry2) or trigger_error("Error 2: " . mysql_error());
            $result3 = mysql_query($qry3) or trigger_error("Error 3: " . mysql_error());   

 

See what is being returned from the mysql error function.

Link to comment
https://forums.phpfreaks.com/topic/184452-query-die/#findComment-973692
Share on other sites

I have to ask why you would even have those queries like that anyways... Why are you grabbing isReading/isPhysical if you already know what they are in the WHERE clause?

 

Is there a better way? I'm doing a count of how many students are registered in each school system that have certain disabilities. This is enclosed in a loop that goes through each school system.

Link to comment
https://forums.phpfreaks.com/topic/184452-query-die/#findComment-973701
Share on other sites

I have to ask why you would even have those queries like that anyways... Why are you grabbing isReading/isPhysical if you already know what they are in the WHERE clause?

 

Now i see what you are saying... I have to grab something right? Can't just have a bunch of blank rows. I suppose i could grab the count but it is just as long coding wise to do that and then read it as it is to report the rows right? I suppose with a large db this would take more resources but with a small one it shouldn't really make a difference right?

Link to comment
https://forums.phpfreaks.com/topic/184452-query-die/#findComment-973712
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.