Jump to content

Recommended Posts

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

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"]."'";

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.