Before anyone jumps on me, I have found a similar issue here, but unfortunately their answer does not seem to apply to my problem.
I have created a function called sqlReturn() in order to more easily produce an error (with standard output) should a query go wrong. The code is below:
function sqlResult($query)
{
return mysql_query($query)
or die("SQL Query: " . $query . "<br />SQL Error: " . mysql_error());
}
As you can see, it just outputs an error in the way I like, and it saves me a bit of effort in coding along the way. However, while this has been working in most cases (eg. situations where I use SELECT or INSERT), it is throwing the following error:
PHP Warning: mysql_fetch_array() expects parameter 1 to be resource,
boolean given in /var/www/login/login_submit.php on line 42
It is returning 1 instead of a resource. If, instead of calling that function (which is in a separate php file), I simply use the line of code in the same file without a return statement
(ie. $sqlResult = mysql_query($sqlQuery) or ... etc.), it returns a resource as normal.
In case it's relevant, my SQL query is also below:
$sqlQuery =
"SELECT userID, username, password, access_level
FROM users
WHERE username = '{$username}'
AND (password = '{$password_sha1}' OR password = '{$password_sha256}')";
Any input on this would be appreciated.
Thanks,
Paragon
mysql_fetch_array()...mysql_query