2011-09-16 53 views
0

我收到此错误:ociparse()预计参数2为字符串

Warning: ociparse() expects parameter 2 to be string, resource given in /home/sjrem/public_html/SIT104_3/order.php on line 29 
An error occurred in parsing the sql string. 

线29:$stmt = OCIParse($connect, $query);

这是我的全部代码:

<html> 
<head> 
<title>Untitled Document</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
</head> 
<body> 



<?php 

/* Set oracle user login and password info */ 
$dbuser = "sjrem"; /* your deakin login */ 
$dbpass = "password"; /* your oracle access password */ 
$db = "SSID"; 
$connect = OCILogon($dbuser, $dbpass, $db); 

if (!$connect) { 
echo "An error occurred connecting to the database"; 
exit; 
} 

$sql = "SELECT * FROM purchase"; 
$query = OCIParse($connect, $sql); 
OCIExecute($query); 

/* check the sql statement for errors and if errors report them */ 
$stmt = OCIParse($connect, $query); 
//echo "SQL: $query<br>"; 
if(!$stmt) { 
echo "An error occurred in parsing the sql string.\n"; 
exit; 
} 
OCIExecute($stmt);?> 


<table> 
<?PHP while (OCIFetch($query)) { 

    $fg1 = OCIResult ($query , "ID") ; echo("<tr><td>id: </td><td>"); echo ($fg1); echo ("</td> </tr>"); 
    $fg2 = OCIResult ($query , "FNAME") ; echo("<tr><td>name</td><td>"); echo ($fg2); echo ("</td> </tr>"); 
    $fg3 = OCIResult ($query , "LNAME") ; echo("<tr><td>email: </td><td>"); echo ($fg3); echo ("</td> </tr>"); 
    $fg4 = OCIResult ($query , "VIN") ; echo("<tr><td>Vin: </td><td>"); echo ($fg4); echo ("</td> </tr>"); 
    $fg5 = OCIResult ($query , "EMAIL") ; echo("<tr><td>Email: </td><td>"); echo ($fg5); echo ("</td> </tr>"); 
    $fg6 = OCIResult ($query , "UNIT") ; echo("<tr><td>Unit: </td><td>"); echo ($fg1); echo ("</td> </tr>"); 
    $fg7 = OCIResult ($query , "STREET") ; echo("<tr><td>Street: </td><td>"); echo ($fg1); echo ("</td> </tr>"); 
    $fg8 = OCIResult ($query , "SUBURB") ; echo("<tr><td>Suburb: </td><td>"); echo ($fg1); echo ("</td> </tr>"); 
    $fg9 = OCIResult ($query , "PCODE") ; echo("<tr><td>Post Code: </td><td>"); echo ($fg1); echo ("</td> </tr>"); 
    $fg10 = OCIResult ($query , "CREDIT") ; echo("<tr><td>Credit: </td><td>"); echo ($fg1); echo ("</td> </tr>"); 
    $fg11 = OCIResult ($query , "HOLDER") ; echo("<tr><td>Holder: </td><td>"); echo ($fg1); echo ("</td> </tr>"); 
    $fg12 = OCIResult ($query , "EXPIRY") ; echo("<tr><td>Expiry: </td><td>"); echo ($fg1); echo ("</td> </tr>"); 


} 





    ?> 
</table> 


</body> 


</html> 
+1

哪部分'ociparse()期望参数2是字符串,资源给定'不清楚? –

+0

看来$ query = OCIParse($ connect,$ sql);没有返回你期望它返回的内容,所以当你在另一个OCIParse中放置$ query时它不起作用 – JSantos

回答

1

$stmt = OCIParse($connect, $query);

$query定义为:$query = OCIParse($connect, $sql);

您不能OCIParse资源,其中$query是。

也许在第29行,你的意思$query = OCIParse($connect, $sql);

+0

非常感谢! – david

+0

没问题,随时标记我的答案(滴答):) – rickyduck

+0

得到了另一个为雅哈哈 http://stackoverflow.com/questions/7443019/php-error-when-trying-to-submit-form -data-to-database-please-help – david

0
$stmt = OCIParse($connect, $query); 

应该是:

$stmt = OCIParse($connect, $sql); 

,取下两行前述它(?你为什么要执行两次吧)

相关问题