I have a page named details.php. Here is its code:
<?
$id = $_GET['id'];
?>
<?
$q = mysql_query("SELECT * FROM `db` WHERE id = $id ");
while($db = mysql_fetch_array($q)) {
?>
<p><?=$db['title']?> <br /> <?=$db['desc']?></p>
<? } ?>
So when I open in browser /details.php?id=1 it works. The paragraph tag shows me the information from id 1. So...
If I replace id with title, it will look like:
<?
$title = $_GET['title'];
?>
<?
$q = mysql_query("SELECT * FROM `db` WHERE title = $title ");
while($db = mysql_fetch_array($q)) {
?>
<p><?=$db['title']?> <br /> <?=$db['desc']?></p>
<? } ?>
If I type in browser /details.php?title=M (M is an existing column in mysql), it doesn't work. I got this error in paragraph: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\mario\game.php on line 51
Where am I wrong?