cs1h Posted September 7, 2007 Share Posted September 7, 2007 Hi, I'm getting the following error message, Parse error: syntax error, unexpected $end in D:\Inetpub\vhost\myroho.com\httpdocs\asearching.php on line 34 The php script is as follows, <?php // Connects to your Database mysql_connect("localhost", "adder", "clifford") or die(mysql_error()) ; mysql_select_db("real") or die(mysql_error()) ; $country = isset($_POST['menuFilesDMA']) ? preg_replace('/[^a-zA-Z0-9\ ]/', '', $_POST['menuFilesDMA']) : ''; $type = isset($_POST['Type']) ? preg_replace('/[^a-zA-Z0-9\ ]/', '', $_POST['Type']) : ''; $Abstract = isset($_POST['keyword']) ? preg_replace('/[^a-zA-Z0-9\ ]/', '', $_POST['keyword']) : ''; $where = array(); if ($country) { $where[] = "country='$country'"; } if ($type) { $where[] = "type='$type'"; } if ($Abstract ) { $where[] = "Abstract LIKE '%$Abstract%'"; } if ($where) { $sql = "SELECT * FROM items WHERE " . implode(' AND ', $where); // query and display results while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<b>country:</b> ".$info['country'] . "<br> "; Echo "<b>type:</b> ".$info['type'] . " <br>"; Echo "<b>Abstract:</b> ".$info['Abstract'] . " <hr>"; } ?> I am new to php and cannot see what my error might be, Any help would be much appriciated, Thanks Colin Link to comment https://forums.phpfreaks.com/topic/68322-unexpected-syntex-error/ Share on other sites More sharing options...
jitesh Posted September 7, 2007 Share Posted September 7, 2007 if ($where) { $sql = "SELECT * FROM items WHERE " . implode(' AND ', $where); // query and display results } Link to comment https://forums.phpfreaks.com/topic/68322-unexpected-syntex-error/#findComment-343541 Share on other sites More sharing options...
beboo002 Posted September 7, 2007 Share Posted September 7, 2007 $sql = "SELECT * FROM items WHERE " . implode(' AND ', $where); u hav error in this line i dont know what u want this query?? ??? Link to comment https://forums.phpfreaks.com/topic/68322-unexpected-syntex-error/#findComment-343542 Share on other sites More sharing options...
ToonMariner Posted September 7, 2007 Share Posted September 7, 2007 jitesh got it - missing a closing brace after the snippet of code he posted. there is nothing wrong with that code Beboo002.... Link to comment https://forums.phpfreaks.com/topic/68322-unexpected-syntex-error/#findComment-343544 Share on other sites More sharing options...
xyn Posted September 7, 2007 Share Posted September 7, 2007 $where = array(); if ($country) { $where[] = "country='$country'"; } if ($type) { $where[] = "type='$type'"; } if ($Abstract ) { $where[] = "Abstract LIKE '%$Abstract%'"; } if ($where) { $where[] automatically starts an array, so you don't need $where = array(); Link to comment https://forums.phpfreaks.com/topic/68322-unexpected-syntex-error/#findComment-343549 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.