MySQL error in PHP for SEO slug -


i have page named details.php. here code:

<? $id = $_get['id']; ?>  <? $q = mysql_query("select * `db` id = $id "); while($db = mysql_fetch_array($q)) { ?>  <p><?=$db['title']?> <br /> <?=$db['desc']?></p> <? } ?> 

so when open in browser /details.php?id=1 works. paragraph tag shows me information id 1. so...

if replace id title, like:

<? $title = $_get['title']; ?>  <? $q = mysql_query("select * `db` title = $title "); while($db = mysql_fetch_array($q)) { ?>  <p><?=$db['title']?> <br /> <?=$db['desc']?></p> <? } ?> 

if type in browser /details.php?title=m (m existing column in mysql), doesn't work. got error in paragraph: warning: mysql_fetch_array() expects parameter 1 resource, boolean given in c:\xampp\htdocs\mario\game.php on line 51

where wrong?

try

$q = mysql_query("select * `db` title = '" . $title . "'"); 

$title string in query have wrap in single quotes

this(mysql_*) extension deprecated of php 5.5.0, , removed in future. instead, mysqli or pdo_mysql extension should used. switching preparedstatements more better ward off sql injection attacks !


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -