No results from mysql query.
Posted: Thu Jul 21, 2011 5:25 am
Hi all, I have the following code and the relevant database and tables set up on a localhost. Yet the query is returning nothing. No error message or results.
If anyone has any ideas why this is not working I would be very grateful. Many thanks in advance.
Code: Select all
<?php
$db_host = 'localhost';
$db_user = 'root';
$db_pass = 'root';
$db_database = 'bbg_db_2';
$dbc = mysql_connect($db_host,$db_user,$db_pass);
$sdb = mysql_select_db($db_database);
$query = "SELECT category_name, category_desc FROM categories";
$result = mysql_query($sdb, $dbc, $query)
or die (mysql_error($dbc));
while($row = mysql_fetch_array($result)) {
$catname = $row["category_name"];
$catdesc = $row["category_desc"];
echo "<li>$catname</br><span>$catdesc</span></a></li>";
}
?>