简体   繁体   English

oci_parse()期望参数1为resource / ociexecute()[function.ociexecute]:ORA-00904

[英]oci_parse() expects parameter 1 to be resource / ociexecute() [function.ociexecute]: ORA-00904

I've recently been working on a uni assignment and had a lot of trouble getting my code to work. 我最近一直在从事单项作业,在使我的代码正常工作方面遇到了很多麻烦。

The errors that seem to occur when I upload my .php file onto the server and then try to view them are the following: 将我的.php文件上传到服务器,然后尝试查看它们时,似乎发生的错误如下:

  1. Warning: oci_parse() expects parameter 1 to be resource, string given in /home/contactusphp.php on line 227 警告:oci_parse()期望参数1为资源,在第227行的/home/contactusphp.php中给出的字符串
  2. Warning: ociexecute() expects parameter 1 to be resource, null given in /home/contactusphp.php on line 232 Your mesage has been sent successfully! 警告:ociexecute()期望参数1为资源,在/home/contactusphp.php的第232行给出空值。您的消息已成功发送!

Additional details: This is for use in an Oracle database, and the original purpose was for a user to use a contact form to send a message to the site owner (putting the message into the database). 其他详细信息:这是在Oracle数据库中使用的,其最初目的是让用户使用联系表向站点所有者发送消息(将消息放入数据库)。

My code is as follows: 我的代码如下:

211. <?
212.        // extract form data 
213.        $emailcontact = $_REQUEST['emailcontact'] ;
214.        $email_address = $_REQUEST['email_address'] ;
215.        
216.        // Create the SQL statement to add data into the database 
217.        $sql = "INSERT INTO contactus (emailcontact, email_address) VALUES ('$emailcontact', '$email_address')";
218.        
219.        // Set the oracle user login and password info
220.        $dbuser = 'XXXX';
221.        $dbpass = 'XXXX';
222.        $db = 'SSID';
223.        $connect = 'OCI_Logon($dbuser, $dbpass, $db)';
224.        
225.        
226.        // Add this data into the database as a new record
227.        $stmt = OCI_Parse($connect, $sql);
228.        if(!stmt) {
229.                echo 'An error occurred in parsing the SQL string./n';
230.                exit;
231.        }
232.        OCI_Execute($stmt); {
233.                echo ('Your mesage has been sent successfully!'); 
234.    } 
235. ?>

I can't seem to find what could be wrong, and I'm not very experienced with web development either. 我似乎找不到可能出问题的地方,而且我对Web开发也不是很有经验。

EDIT: I got rid of quotes, and changed OCI_Logon/OCI_Parse/OCI_Execute to OCILogon, etc. However, the problem changed when I did so. 编辑:我摆脱了引号,并将OCI_Logon / OCI_Parse / OCI_Execute更改为OCILogon,等等。但是,当我这样做时,问题就改变了。

There's a new error code, which is as follows: 有一个新的错误代码,如下所示:

Warning: ociexecute() [function.ociexecute]: ORA-00904: "EMAILCONTACT": invalid identifier in /home/contactusphp.php on line 232 警告:ociexecute()[function.ociexecute]:ORA-00904:“ EMAILCONTACT”:/home/contactusphp.php中第232行的无效标识符

The new code is: 新的代码是:

211. <?
212.        // extract form data 
213.        $emailcontact = $_REQUEST['emailcontact'] ;
214.        $email_address = $_REQUEST['email_address'] ;
215.        
216.        // Create the SQL statement to add data into the database 
217.        $sql = "INSERT INTO contactus (emailcontact, email_address) VALUES ('$emailcontact', '$email_address')";
218.        
219.        // Set the oracle user login and password info
220.        $dbuser = 'XXXX';
221.        $dbpass = 'XXXX';
222.        $db = 'SSID';
223.        $connect = OCILogon($dbuser, $dbpass, $db);
224.        
225.        
226.        // Add this data into the database as a new record
227.        $stmt = OCIParse($connect, $sql);
228.        if(!stmt) {
229.                echo 'An error occurred in parsing the SQL string./n';
230.                exit;
231.        }
232.        OCIExecute($stmt); {
233.                echo ('Your mesage has been sent successfully!'); 
234.    } 
235. ?>

EDIT: The problem ended up fixing itself, and I have no idea how. 编辑:问题最终解决了自己,我不知道如何。

为什么在此函数周围加引号?

$connect = 'OCI_Logon($dbuser, $dbpass, $db)';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM