Hello everyone, this is a quick question. Im trying to look for input that the user made and validate if there's a duplicate or not. so: Steps: 1.check user input. 2.Check database for duplicate. 3.Return false/true. Here's what I tried to do...
include 'db_connect.php'
$username = $_POST['username'];
$result = mysql_query("SELECT 1 FROM members WHERE username = " . mysql_real_escape_string($username));
if ($result && mysql_num_rows($result) > 0) {
$ready = false;
} else {
$ready = true;
}
Here's what Im getting:
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'adminUser'@'localhost' (using password: NO) in/home1/../../../../sec_reg.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home1/../../../../sec_reg.php on line 9
$result=my.... is line 9. Now, what I find weird is that in the SAME file I've got this:
if ($insert_stmt = $mysqli->prepare("INSERT INTO members (username, email) VALUES (?, ?)"))
{
..Some code here
}
And before I added the code with the warning the mysqli->prepare didn't have any problems. What could be happening? **Yes...I checked that db_connect.php was correct.