使用PHP使SQL查询成为字符串

使用PHP使SQL查询成为字符串,php,html,sql,database,oracle-call-interface,Php,Html,Sql,Database,Oracle Call Interface,提交表单时,上面的代码从下拉选择菜单中获取ISBN,stmt是我的sql查询,我使用的是绑定变量(但我也尝试过直接插入ISBN) 我遇到的问题是,我的$isbn变量将其设置为一个数字,我的SQL查询需要varchar2,因此它周围必须有引号。然而,我似乎不能使用\退出PHP,在“:bind1”周围加引号。当查询运行时,您会从数据库中得到一个错误,表示意外的数字。有没有办法在bind1周围加引号?试试: $isbn = strval($_POST['select_catalog']); $conn

提交表单时,上面的代码从下拉选择菜单中获取ISBN,stmt是我的sql查询,我使用的是绑定变量(但我也尝试过直接插入ISBN)

我遇到的问题是,我的$isbn变量将其设置为一个数字,我的SQL查询需要varchar2,因此它周围必须有引号。然而,我似乎不能使用\退出PHP,在“:bind1”周围加引号。当查询运行时,您会从数据库中得到一个错误,表示意外的数字。有没有办法在bind1周围加引号?

试试:

$isbn = strval($_POST['select_catalog']);
$conn = oci_connect($username, $password, $db);
$stmt = oci_parse($conn, 
   "select title_name, author, pub_name, price, qty_on_hand ".
   "from publisher, title ".
   "where publisher.pub_no = title.pub_no and ".
   "isbn = :bind1");
oci_bind_by_name($stmt, ":bind1", $isbn, 10);
oci_execute($stmt, OCI_DEFAULT);
尝试:

尝试:

尝试:


你不需要引用它

oci_bind_by_name($stmt, ":bind1", strval($isbn), 10);

尝试指定类型并将参数强制转换为字符串。

您不需要引用它

oci_bind_by_name($stmt, ":bind1", strval($isbn), 10);

尝试指定类型并将参数强制转换为字符串。

您不需要引用它

oci_bind_by_name($stmt, ":bind1", strval($isbn), 10);

尝试指定类型并将参数强制转换为字符串。

您不需要引用它

oci_bind_by_name($stmt, ":bind1", strval($isbn), 10);

尝试指定类型并将参数强制转换为字符串。

将类型添加到
oci\u-bind\u by\u-name
perhapsad-type添加到
oci\u-bind\u by\u-name
perhapsad-type添加到
oci\u-bind\u by\u-name
perhapsad-type添加到
oci\u-bind\u by\u-name
的末尾