Re: PHP & MySQL Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2007. 05. 21, hétfő keltezéssel 09.43-kor Christian Haensel ezt írta:
> Right, here we go... this page has about 1000 lines of code, so here the 
> relevant stuff.
> 
> $s_query = "SELECT * FROM database WHERE
>  kategorie LIKE '$s_cat' AND
>  marke LIKE '$s_marke' AND
>  leistung_kw >= '$kw_von' AND leistung_kw <= '$kw_bis' AND
>  preis >= '$s_preis_von' AND
>  preis <= '$s_preis_bis'".$checkboxes.$sort_str;
> 
> I get the $checkboxes from the POST checkboxes, which looks like this (an 
> example):
> 
> $kraftstoffart = $_POST['fueltype'];
> if($kraftstoffart == "3") {
>  $checkboxes .= "";
> }elseif($kraftstoffart == "2") {
>  $checkboxes .= " AND kraftstoffart = '2'";
> }elseif($kraftstoffart == "1") {
>  $checkboxes .= " AND kraftstoffart = '1'";
> }
> 
> and the $sort_str comes in like
> 
> $sort_by = $_POST['sort_by'];
> $desc_asc = $_POST['desc_asc'];
> $sort_str = " ORDER BY ".$sort_by." ".$desc_asc;
> 
> 
> The query then just goes like
> $do_q   = mysql_query($s_query) or die(mysql_error());
> 
> and that's it...  no errors shown, just the regular output which I had 
> before I put the new fields in there. So no changes to what I've had 
> before... but there should be changes *g*

actually there seems to be no problem with your query (besides that you
should check posted values first in order to avoid SQL injection)

you said in your first letter that "$_POST['var'] don't reach the
script" - I would guess the relevant part is not the query but rather
the form itself...

greets
Zoltán Németh

> 
> I hope anybody can find some sense in what I'm writing here... hardly makes 
> sense to me :oP
> 
> Cheers!
> 
> 
> 
> 
> 
> 
> 
> ----- Original Message ----- 
> From: "Zoltán Németh" <znemeth@xxxxxxxxxxxxxx>
> To: "Christian Haensel" <php@xxxxxxxxx>
> Cc: <php-general@xxxxxxxxxxxxx>
> Sent: Monday, May 21, 2007 9:36 AM
> Subject: Re:  PHP & MySQL Problem
> 
> 
> > 2007. 05. 21, hétfő keltezéssel 09.26-kor Christian Haensel ezt írta:
> >> Good morning friends,
> >>
> >> I have a script that collects data from a form and puts together a mysql
> >> query to search a database.
> >> Now, everything worked fine until I added a few new form fields... now 
> >> the
> >> $_POST['var'] don't reach the script...
> >>
> >> I have about 20 to 25 form fields which are all taken into the query...
> >>
> >> Now my question: is there a limit in the fields that I can use in the 
> >> query
> >> string to query the database? Somehow the script doesn't even output the
> >> value of the POST data anymore... been using this stuff for years now, 
> >> and
> >> i'm feeling really silly at the moment.
> >
> > AFAIK there is no limit in the number of fields in a query...
> > post some code please, otherwise I don't think anyone will be able to
> > help you
> >
> > greets
> > Zoltán Németh
> >
> >>
> >> I'd appreciate any help.
> >>
> >> Cheers!
> >> Chris
> >>
> > 
> 

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux