Jump to content

[SOLVED] MySQL problem: Warning: mysql_fetch_assoc(): supplied argument is not a valid M


tmyonline

Recommended Posts

Dear all,

 

My PHP program displays this error

 

"Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\htdocs\Test\index.php on line 61"

 

I don't see anything wrong with my syntax or logics; my program works fine as expected although this error appears on the top of the output everytime.  Any idea on how to get rid of this error or hide it ?

 

Thanks a lot!

Tommy

Link to comment
Share on other sites

The error occurs on lines 61, 65, 70, 74, 79:

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\htdocs\Test\index.php on line 61

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\htdocs\Test\index.php on line 65

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\htdocs\Test\index.php on line 70

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\htdocs\Test\index.php on line 74

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\htdocs\Test\index.php on line 79

 

 

Here's a portion of my code where the problem arises:

 

 

$max = 21569;

  if (!isset($_POST['request']) || isset($_POST['submit'])) {

    do {

      $_SESSION['n'] = rand(1, $max);

      $m = $_SESSION['n'];

 

                $imgSQL      = "SELECT * FROM loc_item WHERE LOC_key = $m";

                $imgResult  = mysql_db_query($db,$imgSQL,$cid);

                $imgRow      = mysql_fetch_assoc($imgResult);

 

                $expSQL      = "SELECT * FROM experiences_loc_item_jn WHERE LOC_key = $m";

                $expResult  = mysql_db_query($db,$expSQL,$cid);

                $expRow      = mysql_fetch_assoc($expResult);

                $EXPERIENCES = $expRow['experiences'];

 

                $gradeSQL    = "SELECT * FROM experiences WHERE experiences_key = $EXPERIENCES";

                $gradeResult = mysql_db_query($db,$gradeSQL,$cid);

(line 61)      $gradeRow    = mysql_fetch_assoc($gradeResult);

 

                $subjSQL    = "SELECT * FROM experiences_subjects_jn WHERE experiences_key = $EXPERIENCES";

                $subjResult  = mysql_db_query($db,$subjSQL,$cid);

(line 65)      $subjRow    = mysql_fetch_assoc($subjResult);

                $SUBJECT    = $subjRow['subject'];

 

                $subNameSQL    = "SELECT * FROM subject WHERE subject_key = $SUBJECT";

                $subNameResult = mysql_db_query($db,$subNameSQL,$cid);

(line 70)      $subNameRow    = mysql_fetch_assoc($subNameResult);

 

                $teacherKeySQL    = "SELECT * FROM experiences_teachers_jn WHERE experiences_key = $EXPERIENCES";

                $teacherKeyResult = mysql_db_query($db,$teacherKeySQL,$cid);

(line 74)      $teacherKeyRow    = mysql_fetch_assoc($teacherKeyResult);

                $TEACHERKEY      = $teacherKeyRow['teacher'];

 

                $teacherSQL    = "SELECT * FROM teachers WHERE teachers_key = $TEACHERKEY";

                $teacherResult = mysql_db_query($db,$teacherSQL,$cid);

(line 79)      $teacherRow    = mysql_fetch_assoc($teacherResult);

 

    } while (($imgRow['image'] == "") || ($gradeRow['gradeused'] == "") || ($subNameRow['name'] == "") || ($teacherRow['f_name'] == "") ||            ($teacherRow['l_name'] == ""));

  }

 

 

Many thanks guys!

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.