エラーが発生しているようで、通常はすべてうまくいきますが、疲れていて、どこが間違っているのかわかりません。
次のエラーが表示されます。
Notice: Unknown column 'test' in 'where clause'SELECT * FROM settings WHERE player = `test` in C:\xampp\htdocs\ranking\search.php on line 18
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\ranking\search.php on line 26
Unknown column 'test' in 'where clause'
ローカルホストで使用しているphpコードは次のとおりです。
<?php
//database infomation
$dbhost = "localhost";
$dbname = "databasesname";
$dbuser = "root";
$dbpass = "";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
if(isset($_POST['search'])) {
$searchinfo = $_POST['searchinfo'];
$type = $_POST['group1'];
if($type == "class"){
} else {
$query = "SELECT * FROM settings WHERE player = `$searchinfo`";
$result = mysql_query($query) or trigger_error(mysql_error().$query);
echo "<table><tr><th>Username</th>";
echo "<th> </th>";
echo "<th>Created</th>";
echo "<th>Infastructure</th>";
echo "<th>Statename</th>";
echo "<th>Money</th></tr>";
while ($row = mysql_fetch_array($result) or die($result."<br/><br/>".mysql_error())) {
echo '<tr><td>'
. $row['player'] . '</td><td>'
. $row['data_type'] . '</td><td>'
. $row['data'] . '</td><td> ';
} }
}
?>
<html>
<head>
<rel href="includes/style.css" type="text/css">
<title> Ranking System for Herocraft | Search </title>
</head>
<center>
<div id="searchbar">
<form method="POST" action="<?=$_SERVER['PHP_SELF']?>">
<input type="radio" name="group1" value="username">Username
<input type="radio" name="group1" value="class">Class
<input name="searchinfo" id="searchinfo" size="30" value="Enter your search" maxlength="30" />
<input type="submit" name="search" value="search" /><br />
</form>
</div>