dylanmhulderman;10989031 wrote:Try this... instead of leaving your variables inside of the quotes, exit the quote and then put the variable in, like so:
$query ="INSERT INTO users(username, password, email) VALUES('".mysql_real_escape_string($username)."', '".mysql_real_escape_string($password)."', '".mysql_real_escape_string($email)."')";
Or, for a much cleaner representation, I like to use [man]sprintf/man:
$query = sprintf(
"INSERT INTO users(username, password, email) VALUES ('%s', '%s', '%s')",
mysql_real_escape_string($_POST['username']),
mysql_real_escape_string($_POST['password']),
mysql_real_escape_string($_POST['email'])
);
dylanmhulderman;10989031 wrote:Also, get a password for you MySQL database because maybe somebody hacked in and changed the password or messed with the tables. People can do that if you don't have a password.
... only if you create user accounts that allow connections from external IPs. Since this is almost always unnecessary, a good DBA would only allow either 'localhost' or other internal IPs. Granted, that DBA would also probably enforce a password policy on top of that.