开发者

How can I include characters like "@" or "." in a MySQL table? [closed]

开发者 https://www.devze.com 2023-03-07 23:46 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, 开发者_如何学Goincomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form.
It's difficult to tell what is being asked here. This question is ambiguous, vague, 开发者_如何学Goincomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

When users signup for a site and have spaces, periods, or @ in the usernames it seems to create problems. How can I include these characters?


MySQL couldn't care less about characters in a username or password, unless you're not constructing your query properly:

$password = $_POST['password'];
$username = $_POST['username'];

$quoted_pass = mysql_real_escape_string($password);
$quoted_user = mysql_real_escape_string($username);

$sql = "INSERT INTO users (username, password) VALUES ('$quoted_pass', '$quoted_user');
$result = mysql_query($sql) or die(mysql_error());

if (mysql_affected_rows($result) != 1) {
   die("User record not created");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消