Re: Re: Help: Database Search
| From: | Stuart Felenstein | Date: | Sat, 13 Nov 2004 13:31:06 +0000 |
| Subject: | Re: Re: Help: Database Search | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201908@lists.php.net to get a copy of this message | ||
--- Jason Wong <php-general@gremlins.biz> wrote:
> Yes, that was apparent from your previous post. So
> did you print out your
> query and examine it for any obvious mistakes? And
> if you couldn't spot any
> obvious mistakes then the least you could have done
> was to copy and paste the
> full query in your post so that we could see it in
> all its glory instead of
> the truncated query that was posted as part of the
> mysql error message.
> Please help us to help you.
>
> --
> Jason Wong -> Gremlins Associates ->
It was not apparent whatsoever. Let me show the code
again , but I'll include the print_r returns inline
code.
<?php
$where = array();
$Ind[] = "";
print_r($Ind);
//Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5
[5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 [10] =>
11 [11] => 12 [12] => 13 [13] => 14 [14] => 15 [15] =>
16 [16] => 17 [17] => 18 [18] => 19 [19] => 20 [20] =>
21 [21] => 22 [22] => 23 [23] => 24 [24] => 25 [25] =>
26 [26] => 27 [27] => 28 [28] => 35 [29] => [30] =>
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5
[5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 [10] =>
11 [11] => 12 [12] => 13 [13] => 14 [14] => 15 [15] =>
16 [16] => 17 [17] => 18 [18] => 19 [19] => 20 [20] =>
21 [21] => 22 [22] => 23 [23] => 24 [24] => 25 [25] =>
26 [26] => 27 [27] => 28 [28] => 35 ) )
So maybe this is weird, since it seems to print out
twice ?
if (count($Ind) > 0)
{
$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 );
print_r($where);
//Array ( [0] => VendorJobs.Industry
IN(1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','35','','Array)
)
$result = mysql_query($sql) or die ("Query failed: "
.mysql_error());
while($row = mysql_fetch_assoc($result))
?>
Stuart