SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: PHP/MySQL warning

  1. #1
    SitePoint Addict
    Join Date
    Jul 2002
    Location
    Paciano, Italia
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP/MySQL warning

    I have the following code which is giving me a warning when it runs
    PHP Code:
      $sql "SELECT * FROM keyareas ORDER BY seq_no";
      
    $keyareas = @mysql_query($sql);
      if (!
    $keyareas) {
        echo 
    '<p class="error">Error retrieving data!<br />Error: '.mysql_error().'</p>'
        exit(); 
      } 
      while (
    $keyarea mysql_fetch_array($keyareas)) {
        
    $keyarea $keyarea["keyarea"];
        
    $fieldid "keyarea-".str_replace(" ""_"$keyarea);
        echo 
    '<label for="'.$fieldid.'"><input type="checkbox" name="'.$fieldid.'" id="'.$fieldid.'"'
        if (
    strstr($keyareas$keyarea)) echo ' checked="checked"';
        echo 
    ' /> '.$keyarea.'</label>'."\n";
      } 
    The warning is strstr() expects parameter 1 to be string, resource given. I have similar code for several other tables within the same script which are not giving error messages. Not sure what I'm missing...
    blessed are the cracked for they let in the light

  2. #2
    From Italy with love bronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    8,602
    Mentioned
    76 Post(s)
    Tagged
    4 Thread(s)
    $keyareas is the mysql result set. I'm sure you are using something else for the other tables. If you post one of those similar pieces of code, we should be able to tell you the difference.

  3. #3
    SitePoint Addict
    Join Date
    Jul 2002
    Location
    Paciano, Italia
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, grazie, Guido. I see the error of my ways. It should have been $akeyareas.

    Again, many thanks
    blessed are the cracked for they let in the light

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
  •