Syntax error after host upgraded from 5.0 to 5.1

Discussion in 'MySQL' started by medialab, Apr 11, 2009.

  1. #1
    Hi, I am not really great at programing so any help would be more than appriciated!

    I am getting a syntax error message about this argument: mysql_fetch_array

    It has been working fine until 3 days ago my host upgraded from MySQL 5.0 to 5.1 any ideas??

    <?
    $newban = mysql_query ("select banner from idev_banners where id = $banid");
    $banid = mysql_fetch_array($newban);
    $imgid = $banid[banner];
    ?>
    Code (markup):
     
    medialab, Apr 11, 2009 IP
  2. oarcadescript

    oarcadescript Peon

    Messages:
    34
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try <?
    $newban = mysql_query ("SELECT `banner` from idev_banners where `id` = '".$banid."'");
    $banid = mysql_fetch_array($newban);
    $imgid = $banid['banner'];
    ?>

    just a thought. check your capitals too, your host might have made your table case sensitive.

    If you post the whole error it'll make our lives much easier;)
     
    oarcadescript, Apr 12, 2009 IP
  3. tharshan

    tharshan Active Member

    Messages:
    333
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #3
    try this..it will load and display all banners as list..
    <?
    $newban = mysql_query ("select banner from idev_banners where id = $banid");
    while($banid = mysql_fetch_array($newban))
    {
    $imgid = $banid['banner'];
    echo $imgid."<br>";
    }
    ?>
     
    tharshan, Apr 12, 2009 IP
  4. oarcadescript

    oarcadescript Peon

    Messages:
    34
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    since they're loading by ID, its safe to say theres on one tharshan.
     
    oarcadescript, Apr 12, 2009 IP
  5. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #5
    Use mysql_error() to identify error.

    $newban = mysql_query ("select banner from idev_banners where id = $banid") or die("Error: ". mysql_error());
    Code (markup):
     
    mwasif, Apr 12, 2009 IP
  6. eamiro

    eamiro Well-Known Member

    Messages:
    274
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #6
    Use WHERE instead where
    Use $imgid = $banid['banner']; instead $imgid = $banid[banner];
     
    eamiro, Apr 12, 2009 IP
  7. medialab

    medialab Well-Known Member

    Messages:
    366
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    138
    Digital Goods:
    1
    #7
    I added the or die part and this is what it said:

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/******/public_html/ads/banners.php on line 11

    Warning: Cannot modify header information - headers already sent by (output started at /home/hubalo/public_html/ads/banners.php:11) in /home/*****/public_html/ads/banners.php on line 13

    Line 11 in the banners.php file is the same thing:

    $banid = mysql_fetch_array($newban);

    I am so lost....
     
    medialab, Apr 12, 2009 IP
  8. medialab

    medialab Well-Known Member

    Messages:
    366
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    138
    Digital Goods:
    1
    #8
    Tried this - it didn't work, same error result
     
    medialab, Apr 12, 2009 IP
  9. medialab

    medialab Well-Known Member

    Messages:
    366
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    138
    Digital Goods:
    1
    #9
    This did not work either - same error message
     
    medialab, Apr 12, 2009 IP
  10. medialab

    medialab Well-Known Member

    Messages:
    366
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    138
    Digital Goods:
    1
    #10
    I also checked to see if any of the database tables were case sensetive, and they are not, they all look the same (from what I can tell!)
     
    medialab, Apr 12, 2009 IP
  11. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #11
    <?
    $newban = mysql_query ("select banner from idev_banners where id = '$banid' ");
    $banid = @mysql_fetch_array($newban);
    $imgid = $banid['banner'];
    ?>
    copy paste that
     
    crivion, Apr 12, 2009 IP
  12. medialab

    medialab Well-Known Member

    Messages:
    366
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    138
    Digital Goods:
    1
    #12
    Still have the same error.... Anyone? Any other ideas? :(

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/*****/public_html/ads/banners.php on line 11

    Warning: Cannot modify header information - headers already sent by (output started at /home/hubalo/public_html/ads/banners.php:11) in /home/*****/public_html/ads/banners.php on line 13
     
    medialab, Apr 14, 2009 IP
  13. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #13
    Did you use mysql_error() as I suggessted?

     
    mwasif, Apr 15, 2009 IP
  14. medialab

    medialab Well-Known Member

    Messages:
    366
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    138
    Digital Goods:
    1
    #14
    Yes I did, the error message above is what was on the page after I did.
     
    medialab, Apr 15, 2009 IP
  15. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #15
    mysql_error() will show you the query error, not the PHP error
     
    mwasif, Apr 17, 2009 IP
  16. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #16
    Can you tell how did you use mysql_error() with your code? It is better to post the piece of code where you have used mysql_error().
     
    mwasif, Apr 17, 2009 IP