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
https://forums.phpfreaks.com/topic/189374-whats-wrong-with-my-php-where-clause/
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.  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.