Verify.php

When I try to plug in my information the warning message I get is: “Deprecated: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /var/www/verify.php on line 15
Error: Duplicate entry ‘’ for key ‘username’”. I am not sure what to do I have verify.php code, along with Register.php code, and I am connected to my users datbase. Can any one help me???
Here is my verify.php code:

<?php $dblink = mysqli_connect("localhost", "root", "student", "db1"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n". mysqli_connect_error()); exit(); } if ($_POST['form_submitted'] == '1') { ##User is registering, insert data until we can activate it $activationKey = mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand(); $username = mysql_real_escape_string($_POST[username]); $password = mysql_real_escape_string($_POST[password]); $email = mysql_real_escape_string($_POST[email]); $sql="INSERT INTO users (username, password, email, activationkey, status) VALUES ('$username', '$password', '$email', '$activationKey', 'verify')"; if (!mysqli_query($dblink, $sql)) { die('Error: ' . mysqli_error($dblink)); } echo "An email has been sent to $_POST[email] with an activation key. Please check your mail to complete registration."; ##Send activation Email $to = $_POST[email]; $subject = "JessicaPrice.com Registration"; $message = "Welcome to our website! You, or someone using your email address, has completed registration at YOURWEBSITE.com. You can complete registration by clicking the following link: http://localhost/verify.php?$activationKey If this is an error, ignore this email and you will be removed from our mailing list. Regards, JessicaPrice.com Team"; $headers = 'From: [email protected]' . "\n" ; 'Reply-To: [email protected]' . "\n" ; 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); } else { ##User isn't registering, check verify code and change activation code to null, status to activated on success $queryString = $_SERVER['QUERY_STRING']; $query = "SELECT * FROM users"; $result = mysqli_query($dblink, $query) or die(mysqli_error($dblink)); while($row = mysqli_fetch_array($result)){ if ($queryString == $row["activationkey"]){ echo "Congratulations!" . $row["username"] . " is now the proud new owner of an JessicaPrice.com account."; $sql="UPDATE users SET activationkey = '', status='activated' WHERE (id = $row[id])"; if (!mysqli_query($dblink, $sql)){ die('Error: ' . mysqli_error($dblink)); } } ## end if } ## end while } ## end else ?>

This is my Register.php code :

Username:
Password:
Email:

If you’re using mysqli for the db connection, why are you using mysql for everything else? What version of mysql are you using?

Sponsor our Newsletter | Privacy Policy | Terms of Service