Forum Moderators: coopster

Message Too Old, No Replies

A query with value range

something does not look OK

         

henry0

8:21 pm on Sep 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



the syntax by the end of the query
does not look correct

what do I miss

thanks
regards

Henry

BTW
I am starting gathering info for a query doc
that could describe as many as possible query hacks
but that is another topic that I will post in another thread

mysql_query("SELECT used_value FROM used_equipment WHERE used_value BETWEEN '$mini_value' and '$maxi_value' AND sector='$sector' ' $query ."%' ");

coopster

8:38 pm on Sep 16, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What is in the $query variable? (After the
...sector='$sector'...
) and what is the double quote and percent sign for at the end of your string?

henry0

9:05 pm on Sep 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$query is required by another script section for page counting and other tasks
and the double quotes were not completed
still it does not look correct does it?
mysql_query("SELECT used_value FROM used_equipment WHERE used_value BETWEEN '$mini_value' and '$maxi_value' AND sector='$sector' ". $query ."%' ");

coopster

11:55 am on Sep 17, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Without knowing what is in your $query variable, it is tough to determine the problem. One way that I use to troubleshoot in a test environment is to print out the SQL statement that has been created using the exit() function. I recommend using an
exit($sql);
right after building the $sql variable just to double check your statement. You usually find your answer to unexpected query results (or lack thereof) this way quite quickly. For example:

$sql="SELECT used_value FROM used_equipment WHERE
used_value BETWEEN '$mini_value' and '$maxi_value'
AND sector='$sector' ". $query ."%' ";
exit($sql); // Your code will stop here and print the statement in your browser
mysql_query($query);

If you can't spot it by reviewing the statement that gets displayed in your browser, try cutting and pasting it into an interactive MySQL session. MySQL may offer a more definitive solution.

henry0

12:16 pm on Sep 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Coopster
I should have said that the query has not been tested yet.

I poorly tried to explain that I had a bad feeling about the end of the query
something liek if the sysntax was hurting my eyes without finding the reason why
but since we have moved the double quotes it seems fine
and I will procedd to trial.