I am a newbie in PHP and mySQL. I got stuck with a mySQL function and could not figure out the problem. I would appreciate very much if any expert in this forum could help.
I learned and reused a function get_category_name($catid) from page 554, listing 25.7 of the book PHP and mySQL - web development. The code is as following:
$conn = db_connect();
$query = " select catname
where catid = $catid";
$result = @mysql_query($query);
$num_cats = @mysql_num_rows($result);
if ($num_cats ==0)
$result = mysql_result($result, 0, "catname";
I dont know why mysql_num_rows($result) could not get any value while mysql_query($query) had returned some values in the $result. I got stuck where $num_cats = @mysql_num_rows($result) return false.
Thanks again for any great help.