Page 1 of 1

Accessing MySql with PHP

Posted: Sat Jul 04, 2009 7:01 am
by cjackson111
I have been scratching my head on this one. I have recently moved to a different web server. I have a simple page, pulling data from a table using a where condition. My condition doesn't seem to be working on the new server. I have made no changes to the code (except for the login and password to connect to the database). If I remove the condition it pulls all of the data fine. I am passing the variables ($price1 and $price2) in the url (http://www.......listing.php?price1=0&price2=100000). It worked perfectly on the old server. Any ideas what I may be doing wrong? The select statement is below --

Doesn't work:
$sql = "select * from listing_gah where price > '$price1' and price < '$price2' order by datesold DESC";


Works:
$sql = "select * from listing_gah order by datesold DESC";


PHP Version 5.2.9
MySQL Version 5

Thanks for any help!!

Re: Accessing MySql with PHP

Posted: Sat Jul 04, 2009 12:14 pm
by Peter Anselmo
You could try the "between" syntax as well to see if that works:

Code: Select all

$sql = "SELECT * FROM listing_gah WHERE price BETWEEN '$price1' AND '$price2' ORDER BY datesold DESC";

Re: Accessing MySql with PHP

Posted: Sat Jul 04, 2009 5:36 pm
by cjackson111
Thanks to both of you. Worked like a charm. Don't know why I never used BETWEEN before. Very useful.