RE: [PHP] Re: Help: Database Search

From: Date: Sun, 14 Nov 2004 07:29:57 +0000
Subject: RE: [PHP] Re: Help: Database Search
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-201960@lists.php.net to get a copy of this message
--- Graham Cossey <graham@cossey.plus.com> wrote: > 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 > I think it's working , at least I get results now with no error messages. Still some work to go on the script. Here is the current initializatin and sql code: $Ind = $HTTP_POST_VARS['Ind']; if (count($Ind) > 0 AND is_array($Ind)) { $s_Ind = "'".implode("','", $Ind)."'"; } I guess here I should put this in braces as it should be conditional if $Ind is set, if not the subsequent sql statement shouldn't go in. if ($Ind) $sql .= " WHERE VendorJobs.Industry IN ($s_Ind)"; Stuart

« previous php.general (#201960) next »