php/postgres - 浏览器上的打印问题
我正在开发一个用户/登录系统,其中我下面有一个小的 php 函数,当满足某些条件时(即当用户名和密码匹配时),它会更新数据库中的用户值。但是,登录页面上似乎没有任何反应。我正在使用 Ubuntu,终端上显示变量 $pk_user 为空。问题是我想打印 pk_user 的值,但 echo、print_r、var_dump 不会在浏览器上打印任何内容。我有 CSS 样式,这是原因吗?函数为:
/* updateUserField - Updates a field, specified by the field parameter,
in the user's row of the database, given the pk_user */
public function updateUserField($userkey, $field, $value)
{
$q = "UPDATE users SET ".$field." = '$value' WHERE pk_user = '$userkey'";
pg_query($this->link,$q);
if(pg_last_error($this->link)) {
return -1;
}
return 1;
}
命令行错误信息为:
错误:输入语法无效 整数:“”位于字符 82 语句: 更新用户 SET usr_userid = '9bc44a3b3b0b911f7f932f06ab7d7b5c' 哪里 pk_user = ''
当然,我使用 pg_connect
那部分工作正常。
I am developing a user/login system, wherein I have a small php function below that updates the user values in a DB when certain condition is met (i.e. when username and password matches). However, nothing seems to happen on the login page. I am using Ubuntu and on the terminal it shows that the variable $pk_user is empty. The problem is that I want to print the values of pk_user but echo, print_r, var_dump nothing prints anything on the browser. I have CSS styling, would that be the reason? The function is:
/* updateUserField - Updates a field, specified by the field parameter,
in the user's row of the database, given the pk_user */
public function updateUserField($userkey, $field, $value)
{
$q = "UPDATE users SET ".$field." = '$value' WHERE pk_user = '$userkey'";
pg_query($this->link,$q);
if(pg_last_error($this->link)) {
return -1;
}
return 1;
}
and the error message on command line is:
ERROR: invalid input syntax for
integer: "" at character 82 STATEMENT:
UPDATE users SET usr_userid =
'9bc44a3b3b0b911f7f932f06ab7d7b5c'
WHERE pk_user = ''
Of course I connect to DB with pg_connect
and that part is working okay.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用该函数时,您没有提供整数作为
$userkey
变量。因此,查询失败。检查实际调用函数的代码以确定未传递整数的原因。You're not supplying an integer as the
$userkey
variable when you call the function. Therefore, the query is failing. Check your code where you actually call the function to determine why an integer isn't being passed.