deansaddigh Posted January 21, 2010 Share Posted January 21, 2010 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 More sharing options...
roopurt18 Posted January 21, 2010 Share Posted January 21, 2010 $query = "SELECT * FROM school WHERE town= '.$town.'"; Did you mean: $query = "SELECT * FROM school WHERE town= '".$town."'"; Link to comment https://forums.phpfreaks.com/topic/189374-whats-wrong-with-my-php-where-clause/#findComment-999644 Share on other sites More sharing options...
deansaddigh Posted January 21, 2010 Author Share Posted January 21, 2010 hi why does it need to be wrapped in extra "? Link to comment https://forums.phpfreaks.com/topic/189374-whats-wrong-with-my-php-where-clause/#findComment-999647 Share on other sites More sharing options...
roopurt18 Posted January 21, 2010 Share Posted January 21, 2010 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 https://forums.phpfreaks.com/topic/189374-whats-wrong-with-my-php-where-clause/#findComment-999648 Share on other sites More sharing options...
deansaddigh Posted January 21, 2010 Author Share Posted January 21, 2010 thanks for the help ill read now Link to comment https://forums.phpfreaks.com/topic/189374-whats-wrong-with-my-php-where-clause/#findComment-999649 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.