MySQLデータベースでユーザー固有のWebサイトアクティビティを検索しようとしています。これを行うにはフォームとプロセスを作成して統計表を検索し、クエリと一致するuserIDで記録します。基本的なSELECTを実行中にSQL構文にエラーがあります
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 '@hotmail.com' at line 1
これは私が
<form method='get' action='searchuser.php' id='searchuser'>
<input type='text' input name='txtSearch' id='txtSearch'>
<input type='submit' name='submit' value='Search'>
</form>";
を使用していますし、これは、プロセスのファイル
<?php
require_once("Functions.php");
$header = makeHeader();
$con= connect();
$user = $_GET['txtSearch'];
$query = "SELECT * FROM statistics WHERE userID = $user";
$result=mysql_query($query) or die (mysql_error());
echo"<table border='1'><th>User</th><th>IP</th>
<th>Date</th><th>Page visited</th><th>Page from</th>";
while($row = mysql_fetch_assoc($result))
{
$username = $row['userID'];
$ip = $row['ipAddress'];
$date = $row['dateOfVisit'];
$pagev = $row['pageVisited'];
$pagef = $row['pageFrom'];
echo "<tr><td>".$row->UserID."</td><td>".$row->ipAddress."</td><td>".$row->dateOfVisit."</td><td>".
$row->pageVisited."</td><td>".$row->pageFrom . "<br/>\n"."</td></tr>";
}
IF (mysql_num_rows($queryresult) == "")
{
Echo "<p>Sorry there were no results for your search<p> <br /><br /> <p><A HREF='javascript:javascript:history.go(-1)'>Click here to go back to previous page</A></p>";
}
$footer = makeFooter();
?>
あなたのコードを私のためにこの作業この1
を試すことになる些細なSQLインジェクションの脆弱性です。これを修正する必要があります。 – Romain
[mysqlのinsert文の中にPHP変数を含めるにはどうすればいいですか?](http://stackoverflow.com/questions/7537377/how-to-include-a-php-variable-inside-a-mysql-insert- ) –