hello. i got this error Warning: mysql_db_query(): supplied argument is not a valid MySQL-Link resource in /home/motorbik/public_html/cat page.php on line 49 here is my code <?php $categories = "Gear Reviews"; // setup SQL statement $SQL = " SELECT * FROM Gear Reviews "; $SQL = $SQL . " WHERE categories = '$categories' "; // execute SQL statement $retid = mysql_db_query($db, $SQL, $cid); // check for errors if (!$retid) { echo( mysql_error()); } else { // display results echo ("<p><dt><b>$categories</b><br>\n"); while ($row = mysql_fetch_array($retid)) { $url = $row["url"]; $name = $row["name"]; $description = $row["description"]; echo ("<p><a href='$url'>$name</a></p>\n"); } echo ("</dt></p>"); } ?> PHP:
I think the error is in one of the lines $SQL = " SELECT * FROM Gear Reviews "; $SQL = $SQL . " WHERE categories = '$categories' "; PHP: Why don't you simplify the query $SQL = "SELECT * FROM Gear Reviews WHERE categories = '$categories'"; PHP: I think also that 'categories' is a RESERVED word in MySql, try to rename your table field...
okay i changed the table to categ. and got this error now Warning: mysql_db_query(): supplied argument is not a valid MySQL-Link resource in /home/motorbik/public_html/cat page.php on line 48 this is the code changed <?php $categ = "Gear Reviews"; // setup SQL statement $SQL = "SELECT * FROM Gear Reviews WHERE categ = '$categ'"; // execute SQL statement $retid = mysql_db_query($db, $SQL, $cid); // check for errors if (!$retid) { echo( mysql_error()); } else { // display results echo ("<p><dt><b>$categ</b><br>\n"); while ($row = mysql_fetch_array($retid)) { $url = $row["url"]; $name = $row["name"]; $description = $row["description"]; echo ("<p><a href='$url'>$name</a></p>\n"); } echo ("</dt></p>"); } ?> PHP: