Re: SELECT BLAH WHERE BLAH LIKE BLAH not working
| From: | CC Zona | Date: | Thu, 15 Feb 2001 03:59:18 +0000 |
| Subject: | Re: SELECT BLAH WHERE BLAH LIKE BLAH not working | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-39805@lists.php.net to get a copy of this message | ||
In article <NEBBLGJHKKLGPHEAPNADEEEECBAA.peterh@sunrentals.com.au>,
peterh@vfsa.com.au ("Peter Houchin") wrote:
> <form name=search method=POST action="<? $PHP_SELF ?>">
> <input type="text" name="query">
> <input type="submit" name="submit" value="submit">
> </form>
> <? if ($submit){
> echo "<TABLE BORDER=\"0\" CELLPADDING=\"3\"
> CELLSPACING=\"1\"
> BGCOLOR=\"#CCCCCC\" ALIGN=\"CENTER\">\n<tr
> BGCOLOR=\"#CCCCCC\">\n<td
> bgcolor=\"#006699\"><div align=\"center\"><font
> face=\"Helvetica,
> sans-serif\" size=\"3\"
> color=\"#FFFFFF\"><b>Company</b> </td></tr>";
> $result = mysql_query("SELECT company FROM resellers WHERE Company LIKE
> '%$query%'");
> printf("<tr><td> $company </td></tr>\n");
> echo "</table>";
> echo mysql_error();
> }
> ?>
Are you establishing a valid database connection someplace earlier in the
script? If not, then you need to do so first (see mysql_connect
mysql_pconnect, for instance). Also, the resource id for that connection
should be included as the second parameter in your mysql_query() call. You
may find it helpful to read the PHP manual section on mysql and/or a
PHP/MySQL tutorial (ex. phpbuilder.com).
--
CC