Hi, I've been working on a PHP script to search a MySQL database. It's a variation of one I found on Weberdev, but I can't get it to work. When I run it, I get "Warning: Wrong parameter count for mysql_db_query() on line 11" and "Warning: Supplied argument is not a valid MySQL result resource on line 20".
If anyone could help me with it, I'd appreciate it very much.
Here's the code:
<?
if ($search)
{
mysql_connect ('localhost', 'username', 'password');
mysql_select_db ('database');
$srch="%".$search."%";
$query = "select * from table WHERE date LIKE '$srch' || info LIKE '$srch' || refs LIKE '$srch'";
$result = mysql_db_query($query);
echo "Here are the results:<br><br>";
echo "<table width=90% align=center border=1><tr>
<td align=center bgcolor=#00FFFF>Date</td>
<td align=center bgcolor=#00FFFF>Info</td>
<td align=center bgcolor=#00FFFF>Refs</td>
</tr>";
while ($r = mysql_fetch_array($result)) { // Begin while
$date = $r["date"];
$info = $r["info"];
$refs = $r["refs"];
echo "<tr>
<td>$date</td>
<td>$info</td>
<td>$refs</td></tr>";
} // end while
echo "</table>";
} else {
echo "Search string is empty. <br> Go back and type a string to search";
}
?>
Regards,
Christo
If anyone could help me with it, I'd appreciate it very much.
Here's the code:
<?
if ($search)
{
mysql_connect ('localhost', 'username', 'password');
mysql_select_db ('database');
$srch="%".$search."%";
$query = "select * from table WHERE date LIKE '$srch' || info LIKE '$srch' || refs LIKE '$srch'";
$result = mysql_db_query($query);
echo "Here are the results:<br><br>";
echo "<table width=90% align=center border=1><tr>
<td align=center bgcolor=#00FFFF>Date</td>
<td align=center bgcolor=#00FFFF>Info</td>
<td align=center bgcolor=#00FFFF>Refs</td>
</tr>";
while ($r = mysql_fetch_array($result)) { // Begin while
$date = $r["date"];
$info = $r["info"];
$refs = $r["refs"];
echo "<tr>
<td>$date</td>
<td>$info</td>
<td>$refs</td></tr>";
} // end while
echo "</table>";
} else {
echo "Search string is empty. <br> Go back and type a string to search";
}
?>
Regards,
Christo