Jump to content

Hello God(s) Help with an obvious error


Chezshire

Recommended Posts

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)

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :(

 

 

Link to comment
Share on other sites

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.

Link to comment
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.