SQL语句未在PHP中删除 [英] SQL statement not deleting in PHP

查看:110
本文介绍了SQL语句未在PHP中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

echo $_POST['IDnum'];
$result = pg_prepare($conn, "city_delete",
    "DELETE FROM lab5.city WHERE lab5.city.id = $1");
$result = pg_execute($conn, "city_delete", array($_POST['IDnum']));

这将显示要删除的行的正确ID号,并将其在PSQL中删除,但会在PHP内部实现时不能删除?有想法吗?

This displays the correct ID number for the row to be deleted and will delete it inside PSQL, but will not delete when implemented inside the PHP? Any ideas?

推荐答案

尝试一下:

$result = pg_prepare($conn, "city_delete",
'DELETE FROM lab5.city WHERE lab5.city.id = $1');

您使用的双引号使$ 1成为PHP变量而不是字符串。

The double quotes you used make the $1 a PHP variable instead of a string.

在此处查看pg_prepare的示例: http: //php.net/manual/zh-CN/function.pg-prepare.php

See the example for pg_prepare here: http://php.net/manual/en/function.pg-prepare.php

这篇关于SQL语句未在PHP中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆