Trying to make navigation system, php mySQL.
Is my code correct, could it be cause i am runing on local mashine ?
<?
$hostname = 'localhost';
$username = 'root';
$password= '';
$dbname = 'i';
$db = mysql_connect($hostname, $username,$password) or die("Unable to connect to database.");
@mysql_select_db($dbname, $db) or die("Unable to select database.");
$categories_id = $_GET['id'];
$sql = "SELECT * FROM categories WHERE categories_id=$categories_id";
$result = mysql_query("$sql");
while($rad=mysql_fetch_row($result)) {
$categories_name = $rad[1]; // line 55 error
$categories_id = $rad[0];
}
function category() {
echo "This is category, $categories_name.";
}
$sql = "SELECT * FROM categories WHERE path_id=$categories_id";
$result = mysql_affected_rows("$sql");
// second error line 65
function sub_categories() {
echo "<br><br>And these are the sub-categories:";
$sql = "SELECT * FROM categories WHERE path_id=$categories_id";
$result = mysql_query("$sql");
while($rad=mysql_fetch_row($result)) {
echo "$categories_name.";
}
category();
if($result > 0) {
subcategories();
}
/*
Table data categories
categories_id
categories_name
categories_image
path_id
date_added
last_modified
*/
}
?>
This is my code i have, i got an error.
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in ...on line 55
Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in ......on line 65
Could any1 help me with this code ??
Thank you all,
Rutin