note 93017 deleted from language.basic-syntax by danbrown
| From: | danbrown@php.net | Date: | Wed, 19 Aug 2009 19:59:31 +0000 |
| Subject: | note 93017 deleted from language.basic-syntax by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159651@lists.php.net to get a copy of this message | ||
Note Submitter: phpmaster(somewhat)
----
What is wrong in this code. When I run it is says: "Parse error: syntax error, unexpected $end
in /home/a3487048/public_html/search.php on line 48"
<?php
//get data
$button = $_GET['submit'];
$search = $_GET['search'];
if (!$button)
echo "You didn't submit a keyword.";
else
{
if (strlen($search)<=2)
echo "Search term too short.";
else
{
echo "You searched for $search<hr size'1'>";
}
}
//connect to database
mysql_connect("dbhost","user","password");
mysql_select_db("dbname");
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each)
{
$x++;
if ($x==1)
$construct .= "keywords LIKE '%$search_each%'";
else
{
$construct .= " OR keywords LIKE '%$search_each%'";
}
$construct = "SELECT * FROM searchengine WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);
if ($foundnum==0)
echo "Sorry no results found.";
else
echo "$foundnum results found! <p>";
?>