Joh*_*Z12 0 php mysql unity-game-engine
I know this error has been answered before, but I am following a guide to create my first sql database with MAMP, and received this error when opening the database. Could anyone help me troubleshoot this please? I'm sure it's very simple but I followed the guide exactly and can't find any typos or errors.
Is it possible the error has to do with the way I set-up the database or could it be something I did in Unity? I assume the 615 refers to a line of code or an error number? What would be the way to troubleshoot this in the future or to know where the error is?
The guide I followed had me create the script in Sublime Text and save it locally then access it with MAMP. I'm used to coding in C++ and more recently C# so these are hieroglyphics to me.
Warning in .\libraries\sql.lib.php#615
count(): Parameter must be an array or an object that implements Countable
Backtrace
.\libraries\sql.lib.php#2128: PMA_isRememberSortingOrder(array)
.\libraries\sql.lib.php#2079: PMA_executeQueryAndGetQueryResponse(
array,
boolean true,
string 'unityaccess',
string 'players',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/pmahomme/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `players`',
NULL,
NULL,
)
.\sql.php#219: PMA_executeQueryAndSendQueryResponse(
array,
boolean true,
string 'unityaccess',
string 'players',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/pmahomme/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `players`',
NULL,
NULL,
)
Run Code Online (Sandbox Code Playgroud)
This is the code that led to the error message.
<?php
$con = mysqli_connect('localhost', 'root', 'root', 'unityaccess');
//check that connection happened
if (mysqli_connect_errno())
{
echo "1: Connection failed"; //error code #1 = connection failed
exit();
}
$username = $_POST ["username"];
$password = $_POST["password"];
//check if name exists
$namecheckquery = "SELECT username FROM players WHERE username='" . $username . "'";
$namecheck = mysqli_query($con, $namecheckquery) or die("2: Name check query failed"); //error code #2 - name check query failed
if (mysqli_num_rows($namecheck) > 0)
{
echo "3: Name already exists"; //error code #3 - name exists cannot register
echo();
}
//add user to the table
$salt = "\$5\$rounds=5000\$" . "steamedhams" . $username . "\$";
$hash = crypt($password, $salt);
$insertuserquery = "INSERT INTO players (username, hash, salt) VALUES ('" . $username . "', '" . $hash . "', '" . $salt . "');";
mysqli_query($con, $insertuserquery) or die("4: Insert player query failed"); //error code #4 - insert query failed
echo ("0");
?>
Run Code Online (Sandbox Code Playgroud)
转到此文件: .\libraries\sql.lib.php
在第 615 行查找错误。您会发现它count()没有正确关闭,导致boolean传递了 a 而不是array/object。
与此更换整条生产线615 || ((count($analyzed_sql_results['select_expr']) == 1)。
那应该工作。
有关Stuart Clark适用于使用 Ubuntu 18.04LTS 的 PHP 7.2.24 和可能是较新版本的 phpMyAdmin 的较新解决方案,请参阅的答案。如果该解决方案对您有帮助,请支持他的回答。