RE: [PHP] Re: Help: Database Search
| From: | Stuart Felenstein | Date: | Sat, 13 Nov 2004 12:41:42 +0000 |
| Subject: | RE: [PHP] Re: Help: Database Search | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201903@lists.php.net to get a copy of this message | ||
Sorry, I fixed Ind , since the element is named Ind[].
Now I get a different error:
Query failed: You have an error in your SQL syntax.
Check the manual that corresponds to your MySQL server
version for the right syntax to use near
'','','Array)' at line 3
> <?php
> $where = array();
> $Ind[] = "";
> $Ind[] = $_POST['Ind'];
> if (count($Ind) > 1)
> {
> $IndStr = implode("','", $Ind);
> $where[] = "VendorJobs.Industry IN($IndStr)";
> }else{
> $where[] = "VendorJobs.Industry = {$Ind[0]}";
> }
> ?>
> <?php
> $sql = 'SELECT PostStart, JobTitle, Industry,
> LocationState, VendorID
> FROM VendorJobs
> WHERE ' . implode( ' AND ', $where );
>
> $result = mysql_query($sql) or die ("Query failed: "
> .mysql_error());
> while($row = mysql_fetch_assoc($result))
>
> I can't find the problem.
> Anyone see anything ?
>
> Thank you.
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>