hi i have an error in php it is ::::
Notice: Undefined variable: x in E:\wamp\www\search\search.php on line 31
Notice: Undefined variable: construct in E:\wamp\www\search\search.php on line 33
in this code please help :
<?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 <b>$search</b><hr size='1'>";
//connect to our database
mysql_connect("localhost","root","");
mysql_select_db("mysqladmin");
//expload our search term
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each)
{
//construct query
[COLOR="Red"] $x++;[/COLOR]
if ($x==1)
[COLOR="Red"]$construct .= "keywords LIKE '%$search_each%'";[/COLOR]
else
$construct .= "OR keywords LIKE '%$search_each%'";
}
//echo our construct
$construct = "SELECT * FROM searchengine WHERE $construct";
echo $construct;
}
}
?>