I’m using AJAX and MySQL combination to search a database and display the results within the table. Unfortunately it won’t echo the result from the database yet the code has found it.
$in=$_GET['txt'];
$msg="";
if(strlen($in)>0 and strlen($in) <20 ) {
$t=mysql_query("SELECT user FROM users WHERE user LIKE '$in%'");
while($nt=mysql_fetch_array($t)) {
$msg.=$nt[name]."->$nt[id]<br>";
}
}
echo $msg;
The issue seems to be in this part of my code.
You have selected
userbut you want to displaynamewhich the query is not returning so:Note that I’ve added
mysql_real_escape_string()function for preventing mysql injection