Jump to content

noob question, cant find the problem ><


johnz77

Recommended Posts

im getting this error but i cant find the problem ><:

 

Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in C:\xampp\htdocs\cmd\ZOEKFinal.php on line 29

 

 

 

<?php
$dbHost = 'localhost'; 
$dbUser = 'root'; 
$dbPass = 'bla';
$dbDatabase = 'cmd';
$con = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error("Failed to connect to MySQL Server. Error: " . mysql_error());
mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {$dbDatabase}. Error: " . mysql_error());

$error = array();
$results = array();

if (isset($_GET['search'])) {
   $searchTerms = trim($_GET['search']);
   $searchTerms = strip_tags($searchTerms); 
   
if (isset($_GET['search'])) {
   $searchTerms = trim($_GET['search']);
   $searchTerms = strip_tags($searchTerms);
   
   if (strlen($searchTerms) < 3) {
	  $error[] = "De zoekterm moet langer dan 3 letters zijn";
   }else {
	  $searchTermDB = mysql_real_escape_string($searchTerms); 
   }
   
   if (count($error) < 1) {
      $searchSQL = "SELECT titel, omschrijving, afbeelding FROM fotos WHERE ";
{
     if $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}");
}
      if (mysql_num_rows($searchResult) < 1) {
         $error[] = "De zoekterm {$searchTerms} heeft geen resultaten opgleverd";
      }else {
         $results = array(); 
         $i = 1;
         while ($row = mysql_fetch_assoc($searchResult)) {
            $results[] = "{$i}: {$row['omschrijving']}<br />{$row['plaats']}<br />{$row['afbeelding']}<br /><br />";
            $i++;
	 }
   }
}

function removeEmpty($var) {
   return (!empty($var)); 
}
?>

<html>
   <omschrijving>Zoeken</omschrijving>
   <style type="text/css">
      #error {
         color: red;
      }
   </style>
   <titel>
      <?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?>
      <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm">
         Zoeken <input type="text" name="search" value="<?php echo isset($searchTerms)?htmlspecialchars($searchTerms):''; ?>" /><br />        
         <input type="submit" name="submit" value="Search!" />
      </form>
      <?php echo (count($results) > 0)?"Zoek: {$searchTerms} resultaat:<br /><br />" . implode("", $results):""; ?>
   </titel>
</html>

 

 

any help would be apprciated

Link to comment
Share on other sites

try modifying it like this

<?php
$dbHost = 'localhost'; 
$dbUser = 'root'; 
$dbPass = 'bla';
$dbDatabase = 'cmd';
$con = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error("Failed to connect to MySQL Server. Error: " . mysql_error());
mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {$dbDatabase}. Error: " . mysql_error());
$error = array();
$results = array();
if (isset($_GET['search'])) 
{
   $searchTerms = trim($_GET['search']);
   $searchTerms = strip_tags($searchTerms); 
if (isset($_GET['search']))
{
   $searchTerms = trim($_GET['search']);
   $searchTerms = strip_tags($searchTerms);
   if (strlen($searchTerms) < 3) {
  $error[] = "De zoekterm moet langer dan 3 letters zijn";
   }   else {
  $searchTermDB = mysql_real_escape_string($searchTerms); 
   }
   if (count($error) < 1) {
     $searchSQL = "SELECT titel, omschrijving, afbeelding FROM fotos WHERE ";
{
     if $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}");
}
      if (mysql_num_rows($searchResult) < 1) {
         $error[] = "De zoekterm $searchTerms heeft geen resultaten opgleverd";
      }else {
         $results = array(); 
         $i = 1;
         while ($row = mysql_fetch_assoc($searchResult)) {
            $results[] = "{$i}: {$row['omschrijving']}<br />{$row['plaats']}<br />{$row['afbeelding']}<br /><br />";
            $i++;
}
}
}
}
}
function removeEmpty($var) {
   return (!empty($var)); 
}
?>
<html>
   <omschrijving>Zoeken</omschrijving>
   <style type="text/css">
      #error {
         color: red;
      }
   </style>
   <titel>
      <?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?>
      <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm">
         Zoeken <input type="text" name="search" value="<?php echo isset($searchTerms)?htmlspecialchars($searchTerms):''; ?>" /><br />        
         <input type="submit" name="submit" value="Search!" />
      </form>
      <?php echo (count($results) > 0)?"Zoek: {$searchTerms} resultaat:<br /><br />" . implode("", $results):""; ?>
   </titel>
</html>

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.