简体   繁体   English

奇怪的变量/ Mysql问题

[英]Weird Variable / Mysql Issue

I just don't know what to do, and don't know how to search about this weird problem. 我只是不知道该怎么做,也不知道如何搜索这个奇怪的问题。 Here is is: 这是:

All the connection on the page are working correctly, just in case: 页面上的所有连接都正常工作,以防万一:

I Have this code to update an Email on the Database 我有这个代码来更新数据库上的电子邮件

$fUsername = mysql_real_escape_string($_GET['user']);
$fPassword = mysql_real_escape_string($_GET['senha']);
$fEmail = mysql_real_escape_string($_POST['fEmail']);

$sql = "UPDATE usuario SET email='$fEmail ' WHERE username = '$fUsername' and senha = '$fPassword'";
$result=mysql_query($sql);

Now, the Problem: 现在,问题:

This query is not Updating the "Email" field on the BD. 此查询不是更新BD上的“电子邮件”字段。 It just makes the field empty. 它只是让场地空了。

If I echo the $sql var, I get this: UPDATE usuario SET email='teste@gmail.com ' WHERE username = 'teste1' and senha = 'e10adc3949ba59abbe56e057f20f883e' 如果我回显$ sql var,我得到这个:UPDATE usuario SET email='teste@gmail.com'WHERE username ='teste1'和senha ='e10adc3949ba59abbe56e057f20f883e'

If I ran manually this query on the mySQL, it updates the field like I want. 如果我在mySQL上手动运行此查询,它会像我想要的那样更新字段。

If I manually pass a value to the $fEmail var ( $fEmail = "teste@gmail.com" ). 如果我手动将值传递给$ fEmail var( $ fEmail =“teste@gmail.com” )。 It works just fine. 它工作得很好。

The only way that don't work is when I take the value from the Form . 唯一不起作用的方法是从表单中获取值。

Does anyone have the solution for this? 有没有人有这个解决方案? D: d:

You are using $_GET for the username and password, and $_POST for the email. 您使用$_GET作为用户名和密码,使用$_POST作为电子邮件。 Check your form actual submit method, and fix the relevant data fetching. 检查form实际提交方法,并修复相关数据提取。

You should use $_GET['fEmail'] if the form data is being sent via GET. 如果通过GET发送表单数据,则应使用$_GET['fEmail'] $_POST['fEmail'] is not defined in that case, which would explain the behavior you're seeing. $_POST['fEmail']在这种情况下没有定义,这可以解释你所看到的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM