Chezshire Posted June 12, 2008 Share Posted June 12, 2008 I've tired playing with this for a bit - and i'm vexed vexed vexed. I keep getting this error (which repeats three times as shown below) which is returned from one of my functions and i'm at a complete lose. Help? Please? The Error Message arning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/z/a/n/zanland/html/xpg/functions.php on line 737 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/z/a/n/zanland/html/xpg/functions.php on line 737 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/z/a/n/zanland/html/xpg/functions.php on line 737 function listChars () { global $db; $theseChars2 = mysql_query("select codename,id,height,weight,eyes,hair,ethnicity,characteristics,(YEAR(NOW()) - YEAR(dateofbirth)) - (MONTH(NOW()) < RIGHT(dateofbirth,5)) AS age, YEAR(NOW()) as thisYear from cerebra WHERE approved <> '' AND approved IS NOT NULL AND codename IS NOT NULL AND codename <> '' ORDER BY LENGTH(codename) DESC",$db); $z=0; WHILE ($tempy = mysql_fetch_assoc($theseChars2)) { //-----THIS IS LINE #737 WHICH IS MAKING MY LIFE ANNOYING------ $codenameList[$z] = $tempy["codename"]; $codenameID[$z] = $tempy["id"]; As always, any help, guidance or offer of soup is appreciated Thanks guys (I'm just a struggling novice trying to learn) Quote Link to comment https://forums.phpfreaks.com/topic/109823-hello-gods-help-with-an-obvious-error/ Share on other sites More sharing options...
Rayhan Muktader Posted June 12, 2008 Share Posted June 12, 2008 Run the query: "select codename,id,height,weight,eyes,hair,ethnicity,characteristics,(YEAR(NOW()) - YEAR(dateofbirth)) - (MONTH(NOW()) < RIGHT(dateofbirth,5)) AS age, YEAR(NOW()) as thisYear from cerebra WHERE approved <> '' AND approved IS NOT NULL AND codename IS NOT NULL AND codename <> '' ORDER BY LENGTH(codename) DESC" by itself from a command line and see if you get any error. Quote Link to comment https://forums.phpfreaks.com/topic/109823-hello-gods-help-with-an-obvious-error/#findComment-563614 Share on other sites More sharing options...
Chezshire Posted June 12, 2008 Author Share Posted June 12, 2008 I'm not sure how to do that (i'm a real novice). Do i do that by entering this into my code? <? php $result = mysql_query($select codename,id,height,weight,eyes,hair,ethnicity,characteristics,(YEAR(NOW()) - YEAR(dateofbirth)) - (MONTH(NOW()) < RIGHT(dateofbirth,5)) AS age, YEAR(NOW()) as thisYear from cerebra WHERE approved <> '' AND approved IS NOT NULL AND codename IS NOT NULL AND codename <> '' ORDER BY LENGTH(codename) DESC()); ?>' Thank you for your guidance and help. It's almost like getting soup on a cold new england day Quote Link to comment https://forums.phpfreaks.com/topic/109823-hello-gods-help-with-an-obvious-error/#findComment-563616 Share on other sites More sharing options...
kenrbnsn Posted June 12, 2008 Share Posted June 12, 2008 Replace <?php $theseChars2 = mysql_query("select codename,id,height,weight,eyes,hair,ethnicity,characteristics,(YEAR(NOW()) - YEAR(dateofbirth)) - (MONTH(NOW()) < RIGHT(dateofbirth,5)) AS age, YEAR(NOW()) as thisYear from cerebra WHERE approved <> '' AND approved IS NOT NULL AND codename IS NOT NULL AND codename <> '' ORDER BY LENGTH(codename) DESC",$db); ?> with <?php $q = "select codename,id,height,weight,eyes,hair,ethnicity,characteristics,(YEAR(NOW()) - YEAR(dateofbirth)) - (MONTH(NOW()) < RIGHT(dateofbirth,5)) AS age, YEAR(NOW()) as thisYear from cerebra WHERE approved <> '' AND approved IS NOT NULL AND codename IS NOT NULL AND codename <> '' ORDER BY LENGTH(codename) DESC"; $theseChars2 = mysql_query($q,$db) or die("Problem with the query: $q<br>" . mysql_error()); ?> and tell us what error is printed, if any. Ken Quote Link to comment https://forums.phpfreaks.com/topic/109823-hello-gods-help-with-an-obvious-error/#findComment-563621 Share on other sites More sharing options...
Chezshire Posted June 12, 2008 Author Share Posted June 12, 2008 Hello and thank you for that. this is the error i received 'Parse error: parse error, unexpected '<' in /home/content/z/a/n/zanland/html/xpg/functions.php on line 735' Nothing but that displayed - it killed my whole site which wave kind of neat. Just that line of black text on a white background. What did it do that? And i'm guessing I have an extra Greater Than (<) sign somewhere in my code on that page? Look forwards to your answers! -Chex Quote Link to comment https://forums.phpfreaks.com/topic/109823-hello-gods-help-with-an-obvious-error/#findComment-563632 Share on other sites More sharing options...
Vizor Posted June 12, 2008 Share Posted June 12, 2008 Um, the die() function will stop all script execution and in this case output mysql_error(). Yes you read the error right you have a < that shouldn't be there or is in the wrong place. Quote Link to comment https://forums.phpfreaks.com/topic/109823-hello-gods-help-with-an-obvious-error/#findComment-563700 Share on other sites More sharing options...
bluejay002 Posted June 12, 2008 Share Posted June 12, 2008 i think its not related with the mysql_error() since it didnt showed any mysql_error(). i think its a php error... try scan your code... you might have misplaced something foreign. Quote Link to comment https://forums.phpfreaks.com/topic/109823-hello-gods-help-with-an-obvious-error/#findComment-563704 Share on other sites More sharing options...
kenrbnsn Posted June 12, 2008 Share Posted June 12, 2008 Please show us the line you change and the ten or so lines before/after it. Also, what is line 735? Ken Quote Link to comment https://forums.phpfreaks.com/topic/109823-hello-gods-help-with-an-obvious-error/#findComment-563786 Share on other sites More sharing options...
Chezshire Posted June 13, 2008 Author Share Posted June 13, 2008 Thank you - I'm exploring (unsuccessfully mind you but having fun none the less!) ten lines prior to the error line: // =============================================== // ==================== LIST CHARACTERS // =============================================== function listChars () { global $db; $theseChars2 = mysql_query("select codename,id,height,weight,eyes,hair,ethnicity,characteristics,(YEAR(NOW()) - YEAR(dateofbirth)) - (MONTH(NOW()) < RIGHT(dateofbirth,5)) AS age, YEAR(NOW()) as thisYear from cerebra WHERE approved <> '' AND approved IS NOT NULL AND codename IS NOT NULL AND codename <> '' ORDER BY LENGTH(codename) DESC",$db); $z=0; The line with the error: WHILE ($tempy = mysql_fetch_assoc($theseChars2)) { Ten lines after as requested: $codenameList[$z] = $tempy["codename"]; $codenameID[$z] = $tempy["id"]; $appearanceArray=array(); if ($tempy["age"] && $tempy["age"] != $tempy["thisYear"]) { array_push($appearanceArray, $tempy["age"] . " years old"); } if ($tempy["height"]) { array_push($appearanceArray, $tempy["height"]); } if ($tempy["weight"]) { array_push($appearanceArray, $tempy["weight"]); } if ($tempy["hair"]) { array_push($appearanceArray, $tempy["hair"] . " hair"); } if ($tempy["eyes"]) { array_push($appearanceArray, $tempy["eyes"] . " eyes"); } if ($tempy["ethnicity"]) { array_push($appearanceArray, $tempy["ethnicity"]); } Sorry it took me so long to reply (especially when i'm the one begging for help - I'm dealing with cancer and today was one of my less successful days. But i'm still going! Thanks for all the help. While getting chemo i did try this: != instead of <> Still had the same error Quote Link to comment https://forums.phpfreaks.com/topic/109823-hello-gods-help-with-an-obvious-error/#findComment-564542 Share on other sites More sharing options...
Rayhan Muktader Posted June 13, 2008 Share Posted June 13, 2008 Which error are you getting? The unexpected '<' error or the original error? Create a separate php file and do the following: <?php # FIRST CONNECT TO THE DATABASE # THEN $q = "select codename,id,height,weight,eyes,hair,ethnicity,characteristics,(YEAR(NOW()) - YEAR(dateofbirth)) - (MONTH(NOW()) < RIGHT(dateofbirth,5)) AS age, YEAR(NOW()) as thisYear from cerebra WHERE approved <> '' AND approved IS NOT NULL AND codename IS NOT NULL AND codename <> '' ORDER BY LENGTH(codename) DESC"; $theseChars2 = mysql_query($q,$db) or die(mysql_error()); ?> It is possible that all error reporting are off in the php settings and thats why you are not getting an error when your query is not executing correctly. But php does not have a choice about error reporting when fetcharray function gets an invalid parameter. Take care of one problem at a time. First make sure that this query executes correctly. And ask your server admin about command line access to mysql. It will make your life easier. Quote Link to comment https://forums.phpfreaks.com/topic/109823-hello-gods-help-with-an-obvious-error/#findComment-564546 Share on other sites More sharing options...
Chezshire Posted June 18, 2008 Author Share Posted June 18, 2008 Hi Everyone, I figured out what the problem was - and i did it by using PHPfreaks 'unbugging guide!' So this is solved but i'm nto sure how to change the status of this to 'solved'. Thank you! Chez Quote Link to comment https://forums.phpfreaks.com/topic/109823-hello-gods-help-with-an-obvious-error/#findComment-567911 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.