【问题标题】:I am using the following code for updating the table in mysql database. It ain't working [duplicate]我正在使用以下代码来更新 mysql 数据库中的表。它不起作用[重复]
【发布时间】:2016-07-07 01:21:08
【问题描述】:
$query = "update admin set username = $username and password = $password where id = 1;

在 php 中使用此代码的任何替代方法?

【问题讨论】:

  • admin - 表名、用户名和密码是字段名,$username 和 $password 是要在每个字段中分配的值。
  • 没有任何错误检查。
  • 如何在php中使用这段代码?

标签: php mysql xampp


【解决方案1】:

您需要在变量周围使用引号。

试试这个:

$query = "UPDATE admin SET username = '".$username."', password = '".$password."' WHERE id = 1";

希望这会有所帮助。

和平! xD

【讨论】:

  • 成功了。谢谢。
猜你喜欢
  • 1970-01-01
  • 2011-09-12
  • 1970-01-01
  • 2017-04-21
  • 2018-06-27
  • 2013-05-13
  • 1970-01-01
  • 2020-11-17
  • 2020-01-16
相关资源
最近更新 更多