Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.