gpt4 book ai didi

php - 使用 PHP 在 MySQL 中插入电子邮件地址

转载 作者:行者123 更新时间:2023-11-29 04:23:54 28 4
gpt4 key购买 nike

<分区>

在过去的几个小时里,我一直在与一个非常荒谬的错误作斗争。只是我正在制作注册表。用户需要输入电子邮件,邮件将存储在 mysql 表中。 (我必须警告你 - 请忽略安全问题,整个事情只是一个练习)。但是我经常从 sql 中得到以下错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@gmail.com,blqh2@gmail.com,1)' at line 1

html如下:

      <form method="post" action="createnew.php">
<label >user name</label>
<input name="login_id"></br>
<label>password</label>
<input name="password" password></br>
...some more stuff...
<label>Privet e-mail</label>
<input name="prv_email"></br>
<label>Public e-mail</label>
<input name="pub_email"></br>
<label>Are you a reseller</label>
<input type="checkbox" name="reseller"></br>
<input type="submit">
</form>

然后是 PHP:

$login_id=$_POST['login_id'];
$password=$_POST['password'];
...some more stuff...
$pub_email=$_POST['pub_email'];
echo $prv_email;
echo $pub_email;
if (array_key_exists('reseller',$_POST)) {
$reseller=1;
}
else {
$reseller=0;
}
$sql="INSERT INTO users".
"(login_id,password,usr_phone,region,prv_email,pub_email,reseller)".
"VALUES".
"($login_id,$password,$usr_phone,$region,$prv_email,$pub_email,$reseller)"

最后是邮件字段的 MySQL 格式(实际上它们 prv_email 和 pub_email 具有相同的格式)

    Field     | Type         | Collation
----------|--------------|-------------------
pub_email | varchar(255) | utf8_general_ci

我确实尝试了很多东西,但似乎没有任何效果。它总是在@粉碎。还有一件事——我在本地主机上运行这个代码(使用 WAMP),不确定这是否有任何问题可以解决。如果您需要任何其他信息,请告诉我,非常感谢。

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com