SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: while command

  1. #1
    SitePoint Guru
    Join Date
    Jun 2001
    Location
    Australia
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    while command

    Is there a version of php that will not except this "while" code ?
    PHP Code:
    while ($stories mysql_fetch_array($storieslist)) { 
    The errors only come up in the lines that "while" is coded on.

    ERROR.
    Warning: Supplied argument is not a valid MySQL result resource in newsindex.php on line 23

  2. #2
    Shiver me timbers!! anthony_irl's Avatar
    Join Date
    Aug 1999
    Location
    Dublin, Ireland
    Posts
    495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I reckon it's a problem with the SQL statment or the result set returned. Can you post the code for both the database connection and the query.
    Last edited by anthony_irl; Mar 15, 2002 at 10:26.
    Anthony - How's tings?

    24 hours in a day, 24 beers in a case. Coincidence? I think not.
    Contact me by: PM Email NEW! Carrier Pigeon

  3. #3
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure you are not using the variables (mainly $storieslist) more then once in the whole document!

  4. #4
    SitePoint Guru
    Join Date
    Jun 2001
    Location
    Australia
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the code that works fine on my server but it's not working for 1 other webmaster.
    This is the php version which is on the server that gives the error.

    PHP4u Version 2.1
    Based on PHP-4.1.0

    PHP Code:
    $storieslist mysql_query("SELECT name_admin,email_admin,id,title,story1,ok, date_format(date,'$displaydate') AS formatted FROM boxxpro_news WHERE ok='Y' ORDER BY date DESC LIMIT $newsnumber");

    while (
    $stories mysql_fetch_array($storieslist)) {
        
    $id $stories["id"];
        
    $title $stories["title"];
        
    $story1 $stories["story1"];
        
    $time $stories["formatted"];
        
    $name_admin $stories["name_admin"];
        
    $email_admin $stories["email_admin"];
        
    $ok $stories["ok"]; 


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
  •