Jump to content

Unexpected syntex error


cs1h

Recommended Posts

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
Share on other sites

$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
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.