Jump to content

whats wrong with my php where clause


deansaddigh

Recommended Posts

basically nothing is brought back, which it should be.

 

if($_SERVER['REQUEST_METHOD'] == "POST") 
{
/*get the posted data*/
 $country = $_POST["country"];
 $region = $_POST["region"];
 $town = $_POST["town"];
 $weeks = $_POST["weeks"];

}

/***************
* Check to see if variables are empty
**************/
if (isset($country,$region,$town,$weeks)) 
{
$query = "SELECT * FROM school WHERE town= '.$town.'";			  
$result = mysql_query($query, $conn)
or die ("Unable to perform query");	
	  
}

/***************
* get values from sql query
**************/

while($row= mysql_fetch_array($result))
{
echo $name = $row['name'];
echo $address = $row['address']; 
echo $school_fact = $row["school_facts"];
echo $general_info = $row["general_info"];
echo $country =$row["country"];



}

 

if i get rid of the where clause it works.

 

Link to comment
Share on other sites

It didn't have to be.  I could have just as easily removed the two dots (or concatenation operators) surrounding $town

 

If you fully understand strings and string operators, then you'll see why.

http://php.he.net/manual/en/language.types.string.php

http://php.he.net/manual/en/language.operators.string.php

 

If, after reading those, you are still unsure, come back.  :)

Link to comment
Share on other sites

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.