SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is this error?

    Hey,

    I have the following code below where i pull out data from my database. It works perfectly and actually pulls out exactly what i want. But there is an error that i get even though the code works.

    Code is here:-

    PHP Code:
              $sql_mem "SELECT job_location FROM tbl_job_reviews WHERE member_id = .".$_SESSION['MEM_ID']."'"
              
    $result_mem mysql_query($sql_mem); 
              
    $row_mem mysql_fetch_array($result_mem);
              
              
    $sql "SELECT * FROM tbl_job_reviews WHERE authorised = 1 AND job_location LIKE '%" .$row_mem[job_location]. "%' "
              
    $result mysql_query($sql); 
              
    $numrows mysql_num_rows($result);

                  while(
    $row=mysql_fetch_array($result))
                  { 
                      
    //Pull out details here...
                             

    this is the error:-

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /domains/judgethejob.com/http/vinny/search/index.php on line 230

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    Maybe it's dying at the end of the while?

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by billy_111 View Post
    Code is here:-

    PHP Code:
              $sql_mem "SELECT job_location FROM tbl_job_reviews WHERE member_id = .".$_SESSION['MEM_ID']."'"
              
    $result_mem mysql_query($sql_mem); 
              
    $row_mem mysql_fetch_array($result_mem);
              
              
    $sql "SELECT * FROM tbl_job_reviews WHERE authorised = 1 AND job_location LIKE '%" .$row_mem[job_location]. "%' "
              
    $result mysql_query($sql); 
              
    $numrows mysql_num_rows($result);

                  while(
    $row=mysql_fetch_array($result))
                  { 
                      
    //Pull out details here...
                             

    this is the error:-
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /domains/judgethejob.com/http/vinny/search/index.php on line 230
    Where is line 230. Is it the
    Code:
    $row_mem = mysql_fetch_array($result_mem);
    line or the
    Code:
    while($row=mysql_fetch_array($result))
    line.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To this line:-

    $numrows = mysql_num_rows($result);
    Can you see where the problem is?

  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    The error message has mysql_fetch_array in it, not mysql_num_rows
    Are you sure?

    I guessing that if you're seeing results, then the first query is working as the second uses it's result in it.

    If you try
    PHP Code:
                  echo $numrows '<br>';
                 while(
    $row=mysql_fetch_array($result))
                  { 
                                echo 
    $result '<br>';
                      
    //Pull out details here...
                             

    Do you see something like
    resource
    resource
    resource
    .......
    null


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •