[thelist] mysql error [was mysql help]

Phil Turmel philip at turmel.org
Tue Oct 3 06:09:41 CDT 2006


Mark Mckee wrote:
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL 
> result resource in /opt/lampp/htdocs/link_manager/add_link.php on line 16
> 
> <!--POPULATE DROPDOWN BOX -->
> <?
> // Connect to the correct database
> include "dbconnect.php";
> // Select correct fileds to show
> $sql="SELECT id, catagory FROM catagories ORDER BY catagory";
> $result=mysql_query($sql);
> // Populate the OPTIONS variable
> $options="";
> // Fetch the data
> while ($row=mysql_fetch_array($result)) {              <---------line 16
> // Display data in this format
>      $id=$row["id"];
>      $catagory=$row["catagory"];
>      $options.="<OPTION VALUE=\"$catagory\">$catagory</option>\n";
> }
> ?>
> 
> what would i have to do so that the script will detect that no category 
> has been created and output a message to say that?
> 
Mark,

Something else must be wrong, as a zero-rows-result is still a valid 
result.  If you put in an error check right after mysql_query, you'll 
learn more:

if ($result===FALSE)
     printf("Query Error, #%u\n%s\n", mysql_errno(), mysql_error());

Any chance it's the way you are misspelling category?

HTH,

Phil



More information about the thelist mailing list