help database with search php

hi people i am new in php. I will do where I can search in my database.
problem is: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in
my code

[php]require_once (’… / config.php’);

$ conn = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die (mysql_error ());
mysql_select_db (“DB_DATABASE”, $ conn);
$ search = $ _POST [‘search’];
$ sql = mysql_query (“select * from opi where model numbers like ‘% $ search%’ or name like ‘% $ search%’”, $ conn);

while ($ row = mysql_fetch_array ($ sql))
{
echo “

”;
       echo "<td width='60px' height='10px' valign='top' align='left' class='borderdb'>". $ row ['number']. "</ td>";
   echo "</ tr>";
    }

[/php]

Take the spaces out between the $ and the variable name e.g. $variable instead of $ variable

I’d post a full code, but I’m not editing any code to do with mysql_query any more. See the big red warning right here on the PHP website to find out why.

Sponsor our Newsletter | Privacy Policy | Terms of Service