$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
$email = $_REQUEST['email'];
$con = mysqli_connect(...);
$asking = "SELECT MAX( playerNumber ) as playNum FROM Users";
$result = mysqli_query($con , $asking);
$row = mysql_fetch_array($result);
$numberOfPlayer = $row['playNum'] + 1;
$sql =
"INSERT INTO Users VALUES ( " . $numberOfPlayer . ", " . $username . "," . $password ."," . $email . " , 0)";
$result2 = mysqli_query($conn, $sql);
echo $result2;
mysqli_close($con);
如果我在phpmyadmin中询问它给我的answear但是如果我尝试做某事它会给我打印这个错误:
警告:mysql_fetch_array()期望参数1是资源,第8行/home/u521040346/public_html/learning.php中给出的对象
感谢您的帮助。
答案 0 :(得分:2)
你正在混合mysql和mysqli。使用mysqli_fetch_array
。
无论如何,你应该使用预准备语句,你的查询很容易被SQL注入。