mysql_fetch_array(): supplied argument is not a valid

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

mysql_fetch_array(): supplied argument is not a valid

Post by m2babaey »

Hi
I get this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in g:\programs new\easyphp\www\adcenter\bid.php on line 86
code is:

Code: Select all

<?php 
  foreach ($lines as $nrow => $keyword){
$getbid="SELECT id FROM listing WHERE keyword LIKE %$keyword% ORDER BY maxb DESC LIMIT 5";
$fivebids=mysql_query($getbid);

//table data inputs goes here

  
  
     ?>
    <tr>
 
            <td> <?php  $keyword ?> </td>
            <td> <?php getcost($keyword, $id)  ?> </td>
            <td> <?php getrank ($keyword, $id)  ?> </td>
            <td> Auto Bid</td>
            <td> <?php echo $maxb;  ?> </td>
     <?php       while($frow=mysql_fetch_array($fivebids)){ ?>
          
            <td> <?php echo getcost($keyword, $frow['id']) ;  ?> </td>
     
            <?php 
             }
                       
            ?>

  </tr> 
  <?php
       }
?>
what's wrong? :?
thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

$fivebids=mysql_query($getbid) or die(mysql_error().': '.$getbid);
see also: http://dev.mysql.com/doc/refman/5.1/en/ ... rator_like
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post by m2babaey »

thanks
I replaced that line and it says:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%% ORDER BY maxb DESC LIMIT 5' at line 1: SELECT id FROM listing WHERE keyword LIKE %% ORDER BY maxb DESC LIMIT 5
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

string literals have to be marked by single quotes (') for mysql, LIKE '%$keyword%'

$keyword seems to be empty
Post Reply