php 警告:ocifetch() [function.ocifetch]:ORA-24374:在获取或执行和获取之前定义未完成
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19284833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Warning: ocifetch() [function.ocifetch]: ORA-24374: define not done before fetch or execute and fetch
提问by Steven C
Here is my simple search bar for a uni assignment:
这是我对 uni 作业的简单搜索栏:
<form name="search" method="post" action="phone_search.php">
<font size="5">Best Secondhand Mobile Phones Geelong</font> - Search the site:
<input type="text" name="term" />
<input type="submit" name="search" value="Search" />
</form>
Here is my php code which accesses an oracle server:
这是我访问 oracle 服务器的 php 代码:
echo "<h2>Results</h2>";
//Null string entered
if ($term == "")
{
echo "You didn't enter anything!\n";
exit;
}
//Connect to database
$dbuser = "xxxx";
$dbpass = "xxxx";
$db = "SSID";
$connect = OCILogon($dbuser, $dbpass, $db);
//Database connection error
if (!$connect)
{
echo "An error occurred connecting to the database.\n";
exit;
}
//Make all lowercase
$term = strtolower($term);
$query = "'SELECT * FROM Phones WHERE lower($Name) LIKE $term' OR 'SELECT * FROM Phones WHERE lower($OS) LIKE $term' OR 'SELECT * FROM Phones WHERE lower($Chipset) LIKE $term' OR 'SELECT * FROM Phones WHERE lower($CPU) LIKE $term' OR 'SELECT * FROM Phones WHERE lower($GPU) LIKE $term'";
//Perform search
$stmt = OCIParse($connect, $query);
//And display the results
$counter = 0;
while(OCIFetch($stmt))
{
$counter++;
echo OCIResult($stmt, "Name");
echo "<br>";
echo OCIResult($stmt, "OS");
echo "<br>";
echo OCIResult($stmt, "Chipset");
echo "<br>";
echo OCIResult($stmt, "CPU");
echo "<br>";
echo OCIResult($stmt, "GPU");
echo "<br>";
echo "<br>";
}
I get the correct error for a null string, and no null error when something is entered. However, I think that there is a problem with this line:
我得到了空字符串的正确错误,并且在输入某些内容时没有空错误。但是,我认为这一行存在问题:
$query = "'SELECT * FROM Phones WHERE lower($Name) LIKE $term' OR 'SELECT * FROM Phones WHERE lower($OS) LIKE $term' OR 'SELECT * FROM Phones WHERE lower($Chipset) LIKE $term' OR 'SELECT * FROM Phones WHERE lower($CPU) LIKE $term' OR 'SELECT * FROM Phones WHERE lower($GPU) LIKE $term'";
I keep getting this error:
我不断收到此错误:
Warning: ocifetch() [function.ocifetch]: ORA-24374: define not done before fetch or execute and fetch in /home/cstev/public_html/Assignment_2/phone_search.php on line 41
Line 41 is:
第 41 行是:
while(OCIFetch($stmt))
I have intentionally replaced the login details with 'xxxx' before posting.
在发布之前,我特意用“xxxx”替换了登录详细信息。
When I search for this error, I get: Error in PHP search functionIt seems as though someone else had this problem 2 years ago for the same assignment. The answer that he received was that his search term may have been empty. I can tell that this is not the same problem that I'm having as per the null string error message working correctly if the search term entered is blank.
当我搜索此错误时,我得到:PHP 搜索功能中的错误似乎有人在 2 年前为相同的任务遇到了这个问题。他得到的答案是他的搜索词可能是空的。我可以看出,如果输入的搜索词为空白,这与我遇到的空字符串错误消息不同,但它可以正常工作。
If anyone could point me in the right direction, I would be most appreciative!!
如果有人能指出我正确的方向,我将不胜感激!!
For reference, this is my database:
作为参考,这是我的数据库:
DROP TABLE Phones;
CREATE TABLE Phones
( Name VARCHAR2(50),
OS VARCHAR2(50),
Chipset VARCHAR(50),
CPU VARCHAR(50),
GPU VARCHAR2(50),
Image VARCHAR2(50)
);
INSERT INTO Phones VALUES ('HTC Butterfly S', 'Android OS, v4.2.2 (Jelly Bean)', 'Qualcomm APQ8064T Snapdragon 600', 'Quad-core 1.9 GHz Krait 300', 'Adreno 320', 'images/htc-butterfly-s (1).jpg');
INSERT INTO Phones VALUES ('Huawei Ascend P6', 'Android OS, v4.2.2 (Jelly Bean)', 'Huawei K3V2', 'Quad-core 1.5 GHz', 'N/A', 'images/huawei-ascend-p6-ofic.jpg');
INSERT INTO Phones VALUES ('Oppo R819', 'Android OS, v4.2.1 (Jelly Bean)', 'MediaTek MT6589', 'Quad-core 1.2 GHz', 'PowerVR SGX544', 'images/oppo-r819.jpg');
INSERT INTO Phones VALUES ('Sony Xperia M', 'Android OS, v4.1 (Jelly Bean)', 'Qualcomm Qualcomm Snapdragon S4 Plus MSM8227', 'Dual-core 1 GHz Krait', 'Adreno 305', 'images/sony-xperia-m (1).jpg');
INSERT INTO Phones VALUES ('Samsung Galaxy Core', 'Android OS, v4.1.2 (Jelly Bean)', 'Snapdragon MSM8225 S4 Play', 'Dual-core 1.2 GHz Cortex-A5', 'Adreno 203', 'images/samsung-galaxy-core-gt-i8260 (1).jpg');
INSERT INTO Phones VALUES ('Motorola Moto X', 'Android OS, v4.2.2 (Jelly Bean)', 'Qualcomm MSM8960Pro Snapdragon', 'Dual-core 1.7 GHz Krait', 'Adreno 320', 'images/moto-x.jpg');
commit;
回答by Przemyslaw Kruglej
I guess you forgot the
我猜你忘记了
ociexecute($stmt, OCI_DEFAULT);
After the
之后
$stmt = OCIParse($connect, $query);
And before the:
而在此之前:
while(OCIFetch($stmt))
So it would look like this:
所以它看起来像这样:
//Perform search
$stmt = OCIParse($connect, $query);
// Execute statement
ociexecute($stmt, OCI_DEFAULT);
//And display the results
$counter = 0;
while(OCIFetch($stmt))
{
$counter++;
...