[英]oci_parse(): and oci_execute(); warnings
Started using oci_ functions in PHP.开始在 PHP 中使用 oci_ 函数。 Running into the subject error.遇到主题错误。
My database file is as follows:我的数据库文件如下:
<?php
$conn = oci_connect("user", "pass", "LOSINGMINDHOST");
if (!$conn) {
$e = oci_error();
error_log(trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR));
}
oci_close($conn);
?>
Confirmed the above connection string is successful.确认以上连接字符串成功。
Now, in my test file, I have the following:现在,在我的测试文件中,我有以下内容:
<?php
include("include/database.php");
$queryMain = oci_parse($conn, "select * from sometable");
oci_execute($queryMain);
?>
Using the above, here is what I am getting on screen:使用上述内容,这是我在屏幕上看到的内容:
Warning: oci_parse(): supplied resource is not a valid oci8 connection resource in D:\htdocs\mysite\test.php on line 4
Warning: oci_execute() expects parameter 1 to be resource, bool given in D:\htdocs\mysite\test.php on line 26
I am using PHP 7.4 on a Windows Server 2019.我在 Windows Server 2019 上使用 PHP 7.4。
I checked the php.ini file to make sure the oci8 connections are available and/or uncommented out.我检查了 php.ini 文件以确保 oci8 连接可用和/或取消注释。
What else do I need to make this work?我还需要什么才能完成这项工作?
Immediately after you open the connection you close it again.打开连接后立即再次关闭它。 This makes it unusable.这使它无法使用。 Remove the oci_close($conn);
删除oci_close($conn);
call.称呼。
Overall, you might want to look at a different architecture, such as using classes.总的来说,您可能希望查看不同的体系结构,例如使用类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.