here I am once again! I've come accross a rather annoying issue, and i'm pretty sure I'm not doing it wrong.
When I try to check if an username already exists in the MYSQL Database via PHP, it nags about the string being a boolean and not a variable.
This is the PHP code:
if (isset($_POST['Submit1']))
{
$username = $_POST['username'];
if(IsNameInUse($username)) header("Location: cselect.php?exist");
}
else if (isset($_POST['Submit2']))
{
$username = $_POST['username'];
if(IsNameInUse($username)) header("Location: cselect.php?exist");
}
else if (isset($_POST['Submit3']))
{
$username = $_POST['username'];
if(IsNameInUse($username)) header("Location: cselect.php?exist");
}
Here is the "IsNameInUse" from my functions file:
function IsNameInUse($username)
{
$username = mysql_real_escape_string($username);
$query = mysql_query("SELECT COUNT(ID) FROM Accounts WHERE Username = '$username'");
return (mysql_result($query, 0) == 1) ? true : false;
}
I've already performed an: "echo $username;" and this clearly shows that a string is set as $username. It clearly gave me the string I entered. Now, I honestly have no idea why its giving the following error:
[error] PHP Warning: mysql_result() expects parameter 1 to be resource, boolean given in /var/zpanel/hostdata/paradise/public_html/paradiseroleplay_com/includes/functions.php on line 7
So here I am again, asking the never ending knowledge of the internet. Regards, Heartfire.
EDIT Got it fixed. "Sorry for this. The die on mysql error, clearly showed how stupid I can be. I forgot that for Accounts, I made it "AccID" and not "ID"... Thanks a bunch, got it fixed now." And about the DTO, good point -- Will do.