SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Jul 2002
    Location
    Italy
    Posts
    429
    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 silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 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 Evangelist
    Join Date
    Jul 2002
    Location
    Italy
    Posts
    429
    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
  •