Hi Stuart

Not sure what's happening with the $Ind variable, maybe check the $_POST
array as you enter the script to ensure that the form is passing the data
correctly. It is almost as if you are appending it to itself at some point.
You don't have a line like this anywhere do you : $Ind[] = $Ind;  OR maybe 2
of: $Ind[] = $_POST['Ind']; ??

Part of the problem is with the implode statement. It is this that is not
adding the initial and final ' to your IN statement, see below:

  if (count($Ind) > 0)
  {

    $IndStr = implode("','", $Ind);
    $where[] = "VendorJobs.Industry IN('$IndStr')";
                                       ^-------^
  }else{
    $where[] = "VendorJobs.Industry = {$Ind[0]}";
}

I would also remove this line:
$Ind[] = "";

HTH
Graham

> -----Original Message-----
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 13 November 2004 13:31
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Re: Help: Database Search
>
>
>
> --- Jason Wong <[EMAIL PROTECTED]> 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
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to