johnz77 Posted March 19, 2010 Share Posted March 19, 2010 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 https://forums.phpfreaks.com/topic/195784-noob-question-cant-find-the-problem/ Share on other sites More sharing options...
Deoctor Posted March 19, 2010 Share Posted March 19, 2010 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 https://forums.phpfreaks.com/topic/195784-noob-question-cant-find-the-problem/#findComment-1028512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.