我只是想通过特定行中的表获取一些数据。
这是我的脚本。
<?php
$con=mysqli_connect("localhost","root","","astralms");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$type = htmlspecialchars(mysql_real_escape_string($_GET['type']));
$username = htmlspecialchars(mysql_real_escape_string($_GET['username']));
$result = mysqli_query($con,"SELECT * FROM accounts
WHERE name = '%s', $username);
while($row = mysqli_fetch_array($result))
{
if($type == "nxcash") {
echo $row['ACash'];
} else if($type == "votepoints") {
echo $row['vpoints'];
} else if ($type == "gmlevel") {
echo $row['gm'];
}
}
?>
但是,我得到:
( ! ) 解析错误:语法错误,第 17 行 C:\wamp\www\accountdata.php 中出现意外的 'nxcash' (T_STRING)。
像使用它时127.0.0.1/accountdata.php?username=tester&type=votepoints
谢谢。