[thelist] mysql error [was mysql help]

Mark Mckee lists at soddengecko.com
Mon Oct 2 23:23:09 CDT 2006


hi all

thanks to the advice and info from the people here i have managed to 
finish my script.

i do get a slight problem though, when someone tries to add a link when 
a category does not exist, it out puts this mysql error

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

this is the code on that page

<!--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?


kind regards

mark m....



More information about the thelist mailing list