PDA

View Full Version : running Query, but 2 Get statements dont wanna work together


0o0o0
07-19-06, 03:09 PM
running Query, but 2 Get statements dont wanna work together

Cant for the life of me figure out...

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM `BIKES`where prod = '".$typeArray[$_GET['model']]."' AND make = '".$typeArray[$_GET['makes']]."'"),0);

doesnt count the total.

but if I use say...just straight prod = 'YZR' as a prod.. and the rest of the statement stays the same it all works fine.. counts the sum.

but soon as I have two GETs in the same line its doesnt count the sum.

Is there a trick?

Thanks guys. Even a hyperlink to somewhere on tips about this would be just as good!

duesi
07-19-06, 04:37 PM
What did you fill $typeArray with?
What I would do is:


$sql= "SELECT COUNT(*) as Num FROM `BIKES`where prod = '".$typeArray[$_GET['model']]."' AND make = '".$typeArray[$_GET['makes']]."'";

print $sql;

$total_results = mysql_result(mysql_query($sql),0);


Do you get a reasonable sql-string?
I have a feeling your values don't get passed in correctly.

Happy Coding!

Christian
07-20-06, 12:56 AM
Moved to Database.

0o0o0
07-21-06, 11:44 AM
"Moved to Database."

Whats this mean?? new forum?

0o0o0
07-21-06, 01:15 PM
lol ... ima lil slo.

mattyblah
07-27-06, 05:40 PM
I'm guessing your problem is that you're narrowing down the result set too much and not getting a count because there are none that satisfy your criteria. Print the SQL and put it in something like phpmyadmin and see what the results are.

duesi
07-28-06, 01:55 AM
But still he should get a count of 0 if there is nothing left!

0o0o0
07-28-06, 02:24 AM
yeah thats all I get is zero.

although.. if I do this..

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM `BIKES`where prod = 'handle_bars' AND make = '".$typeArray[$_GET['makes']]."'"),0);

It counts 32 and there are 32.

wierd.. its like it doesnt want two $typeArrays in one line. or the TypeArrays have to be numbered?

mab
07-28-06, 08:35 AM
So, does - $typeArray[$_GET['model']] contain a value that matches the prod column, such as your 'handle_bars' value? Is 'model' the same type as the prod column? Also, does $typeArray contain both 'model' and 'makes' information, that seams unusual.

0o0o0
08-14-06, 06:22 PM
model and makes are examples..

its model and parts actually