function DisplayPoints()
{
$con = mysql_connect("localhost", "grame2_admin", "password") ;
if (!$con) {
die("Can not connected: " . mysql_error());
}
mysql_select_db("grame2_webpage",$con);
$sql = "SELECT points FROM tablename WHERE username = $username";
$myData = mysql_query($sql,$con);
while($record = mysql_fetch_array($myData)){
它回显了信息,第164行出现错误,线路超过这个。
echo $record['points'] ;
}
mysql_close($con);
}
主要思想是在网页中回显来自特定用户的INT。请帮忙! :)
答案 0 :(得分:1)
更改
$sql = "SELECT points FROM tablename WHERE username = $username";
到
$sql = "SELECT points FROM tablename WHERE username = '$username'";
^ ^
在旁注中使用带有mysqli或PDO的预准备语句。不推荐使用mysql扩展,不再支持。
更新另一个问题是您的$username
变量未初始化。您可能需要将其作为参数传递给您的函数
function DisplayPoints($username)
{
...
}
当你调用你的函数时传递一个值
DisplayPoints('user1');
或
$username = $_POST['username'];
// here should go code to validate and sanitize $username
DisplayPoints($username);