开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜