2011-11-20 21:31
浏览 323


I'm sure this is something very basic but I can't seem to find my error.

I'm trying to execute the following...

$c = db_connect();

$email = addslashes($email);

$sql = "SELECT * FROM RUSER WHERE email LIKE '" . $email . "';";
$query = oci_parse($c, $sql) or die(oci_error($c));
$response = oci_execute($query) or die(oci_error($c));

but I get oci8 statement Warning: oci_execute(): ORA-00911: invalid character in /path/to/file.php on line 67 where line 67 is where $response is assigned.

So that means there is something wrong with $query right? But I can't seem to find what that would be. The raw sql executes fine from the command line. echoing get_resource_type($query) gives a resource id...

What am I doing wrong?

图片转代码服务由CSDN问答提供 功能建议



  $ c = db_connect(); 
 $ email = addslashes($ email)  ); 
 $ sql =“SELECT * FROM RUSER WHERE email LIKE'”。  $ email。  “';”; 
 $ query = oci_parse($ c,$ sql)或die(oci_error($ c)); 
 $ response = oci_execute($ query)或die(oci_error($ c)); 

但是我得到 oci8语句警告:oci_execute():ORA-00911:第67行的/path/to/file.php中的字符无效第67行是分配 $ response 的地方。

这意味着 $ query 出错了吗? 但我似乎无法找到那将是什么。 原始sql从命令行执行正常。 echoing get_resource_type($ query)给出一个资源ID ...


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongtan1845 2011-11-21 04:01

    Do NOT include the ; in your SQL. The ; is not part of SQL itself, its used by various SQL clients (e.g. sql*plus) as a delimiter to mark the end of commands to be sent to the server.

    点赞 打赏 评论
  • dongzaocheng3214 2012-08-30 04:55

    The first error is

    $c = oci_connect("user","password","host/dbname") // db_connect() is not true

    second error is there should not be ";" in the statement

    $sql = "SELECT * FROM RUSER WHERE email LIKE '" . $email . "';";

    it should be

    $sql = "SELECT * FROM RUSER WHERE email LIKE '" . $email . "'"; 

    if you want to compare better user "=" than LIKE

    点赞 打赏 评论

相关推荐 更多相似问题