mysql search not happening
I don't know where I went wrong but the query isn't taking place:
PHP Code:
<?php
$con = mysql_connect("","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("boti_book", $con);
$sql = "SELECT content FROM boti_pages WHERE content LIKE 'Fritz'";
$result = mysql_query($sql);
echo $sql;
while($row = mysql_fetch_array($result))
{
echo $row['content']."<br />\n";
}
mysql_close($con);
?>
Re: mysql search not happening
If you use mysql_error() you will be able to find out why ;)
Re: mysql search not happening
Quote:
Originally Posted by visualAd
If you use mysql_error() you will be able to find out why ;)
It's there already. Look in the code I posted above.
I don't think there's any error because I typed:
echo "hi";
to test if it's going to output it. And it did.
Re: mysql search not happening
You need to use it after the query too. If the result is false then the query failed.
Re: mysql search not happening
Quote:
Originally Posted by visualAd
You need to use it after the query too. If the result is false then the query failed.
Oh ok. But how?
$result = mysql_error()?
Re: mysql search not happening
PHP Code:
.....
if (! $result) {
mysql_error($conn);
....