I have a form and through which i submit a input.
<form action= "index.php" method="POST">
<input type="text" name="input" required />
<input type="submit" name="submit" value="ask"/>
</form>
in php
$input=$_POST['input'];
suppose i submitted $input='IS BILL %'
i get error as
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IS BILL % limit 1'
when i search for the input in a column of my table in a query..
$getdata= mysql_query("SELECT * FROM aiml WHERE pattern like $input limit 1 ") or die(mysql_error());
if(!$getdata)
echo "no data";
else
{
while ($row = mysql_fetch_assoc($getdata))
{
$text=$row['template'];
echo $text;
}
}
but if in query i write
"SELECT * FROM aiml WHERE pattern like 'IS BILL %' limit 1 ") or die(mysql_error());
i get the expected output.