aeroswat Posted December 8, 2009 Share Posted December 8, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/184452-query-die/ Share on other sites More sharing options...
premiso Posted December 8, 2009 Share Posted December 8, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/184452-query-die/#findComment-973692 Share on other sites More sharing options...
Philip Posted December 8, 2009 Share Posted December 8, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/184452-query-die/#findComment-973696 Share on other sites More sharing options...
aeroswat Posted December 8, 2009 Author Share Posted December 8, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/184452-query-die/#findComment-973701 Share on other sites More sharing options...
mikesta707 Posted December 8, 2009 Share Posted December 8, 2009 Why not just use the MYSQL built in COUNT() function if you are just getting a count clicky Quote Link to comment https://forums.phpfreaks.com/topic/184452-query-die/#findComment-973704 Share on other sites More sharing options...
aeroswat Posted December 8, 2009 Author Share Posted December 8, 2009 Silly me... Thanks promiso. There is an apostrophe in one of the school system names in my db Quote Link to comment https://forums.phpfreaks.com/topic/184452-query-die/#findComment-973707 Share on other sites More sharing options...
aeroswat Posted December 8, 2009 Author Share Posted December 8, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/184452-query-die/#findComment-973712 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.