-1

以下错误:

“警告:oci_execute() [function.oci-execute]: ORA-00911: F:\wamp\www\SEarch Engine\test1.php 第 69 行中的无效字符”

此代码正在生成:

<?php
include_once('config.php');
$db = oci_new_connect(ORAUSER,ORAPASS,"localhost/XE");

$url_name = $_POST['textfield'];
$keyword_name = $_POST['textarea'];
$url_type = $_POST['RadioGroup1'];
$anchor_text = $_POST['textfield2'];
$description = $_POST['textarea2'];   

$sql = "select seq_url1.nextval seq_url1 from dual"; 
$result = oci_parse($db,$sql);

oci_execute($result);   
if($result) 
{
    while($row = oci_fetch_array($result))
    {   
        $temp = $row['SEQ_URL1'];
        echo $temp;
    }
}           

$sql_url1 = 'INSERT INTO URL1(Url_ID,Url_Name,url_Type,Anchor_Text,Dscription) '.'VALUES($temp,:url,:type,:anchor,:description)';

$compiled = oci_parse($db, $sql_url1);

oci_bind_by_name($compiled, ':url', $url_name);
oci_bind_by_name($compiled, ':type', $url_Type);
oci_bind_by_name($compiled, ':anchor', $anchor_text);
oci_bind_by_name($compiled, ':description', $description);

oci_execute($compiled);
?>

这可能是什么原因造成的?

4

4 回答 4

3

这可能是由“描述”的拼写错误引起的:

$sql_url1='INSERT INTO URL1(Url_ID,Url_Name,url_Type,Anchor_Text,Dscription)...
                                                                  ^ here
于 2010-01-26T16:18:48.850 回答
1

这:

$sql_url1 = 'INSERT INTO URL1
                (Url_ID,Url_Name,url_Type,Anchor_Text,Dscription)'.'
             VALUES
                ($temp,:url,:type,:anchor,:description)';

...应该:

$sql_url1 = 'INSERT INTO URL1
                (Url_ID,Url_Name,url_Type,Anchor_Text,Dscription)'.'
             VALUES
                (seq_url1.NEXTVAL,:url,:type,:anchor,:description)';

You don't need two queries to perform the operation, just call the sequence.NEXTVAL within the INSERT statement. The only reason to use what you've got, is if you are re-using that sequence value for other records.

Also, it's possible that Dscription is a typo, that doesn't match the actual column name. Confirm by using DESCRIBE URL1. And you could try printing the query prior to it being run:

oci_bind_by_name($compiled, ':url', $url_name);
oci_bind_by_name($compiled, ':type', $url_Type);
oci_bind_by_name($compiled, ':anchor', $anchor_text);
oci_bind_by_name($compiled, ':description', $description);

echo $sql_url1
于 2010-01-26T16:42:14.473 回答
0

我有根据的猜测是您的 Web 表单的编码与您的 Oracle 数据库和/或连接的编码不匹配。mySQL 会优雅地将损坏的字符写入表中——也许 Oracle 更严格。

但首先要检查一下 George Johnston 或 John Rasch 的观察是否在金钱上是不正确的,并为我们提供一些调试数据来查看。

于 2010-01-26T16:21:11.740 回答
0

You've got a poorly used PHP variable in your query.

$sql_url1 = 'INSERT INTO URL1(Url_ID,Url_Name,url_Type,Anchor_Text,Dscription) VALUES($temp,:url,:type,:anchor,:description)';

In here, $temp is intended to just dump the integer, but since the string uses single quotes no substitution takes place and oracle sees "$temp" (which isn't valid in that context). Switch to double quotes:

$sql_url1 = "INSERT INTO URL1(Url_ID,Url_Name,url_Type,Anchor_Text,Dscription) VALUES($temp,:url,:type,:anchor,:description)";

Or take the above suggestion and use seq_url1.nextval. Description is misspelt, but that will throw an unknown column error, not an invalid character error.

Thanks, Joe

于 2010-01-26T18:34:38.770 回答