jeger003 Posted August 10, 2010 Share Posted August 10, 2010 hello, here is my query $this->sql_query = "SELECT * FROM ".$this->classifieds_table." WHERE category ".$this->in_statement." AND live=1 "; the above works....but when I add {AND location = "".$_COOKIE["State"]."\"} - it doesnt work no matter what location equals it wont read query. as soon as i remove the extra AND it works. help please Quote Link to comment https://forums.phpfreaks.com/topic/210352-php-is-not-working-with-mysql-cant-add-and/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 10, 2010 Share Posted August 10, 2010 The syntax for just the part you are adding should be - AND location = '".$_COOKIE["State"]."' Resulting in the whole query of - $this->sql_query = "SELECT * FROM ".$this->classifieds_table." WHERE category ".$this->in_statement." AND live=1 AND location = '".$_COOKIE["State"]."'"; Quote Link to comment https://forums.phpfreaks.com/topic/210352-php-is-not-working-with-mysql-cant-add-and/#findComment-1097677 Share on other sites More sharing options...
wildteen88 Posted August 10, 2010 Share Posted August 10, 2010 EDIT: Beaten to it $this->sql_query = sprintf("SELECT * FROM %s WHERE category = '%s' AND live=1 AND location = '%s'", $this->classifieds_table , $this->in_statement , mysql_real_escape_string($_COOKIE["State"]) ); If your query is still failing you can get the error message using mysql_error function. Quote Link to comment https://forums.phpfreaks.com/topic/210352-php-is-not-working-with-mysql-cant-add-and/#findComment-1097678 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.