2011-09-16 36 views
-1

這是腳本。我上線29這是得到一個錯誤..試圖從數據庫錯誤中提取數據

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

(比較以及這個問題PHP error: Warning: ociparse() expects parameter 2 to be string

<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 = "sjsrem"; /* your deakin login */ 
$dbpass = "shaz"; /* 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);?> 




<!-- Now we output the data using a table and/or formatted HTML --> 




<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> 
+0

什麼是錯誤訊息? – Sjoerd

+1

單獨向我們展示「第50行」可能也是有用的......不確定其他人,但我不會計數!另外,'$ query'中有什麼? –

+0

對不起: 行50: 警告:ocifetch()預計參數1是資源,在/ home/sjrem /的public_html/SIT104_3空給/order.php第50行 – David

回答

1

參數必須是一個資源,但你逝去的SQL字符串。在您的代碼資源中是$stmt。您需要使用的$stmt代替$query

OCIFetch($stmt) 

也爲OCIResult再次,你需要使用OCIResult($stmt)OCIResult($query)

+0

我意識到我沒有把購買選擇*。 現在我收到第30行的錯誤:$ stmt = OCIParse($ connect,$ query); 錯誤:警告:ociparse()期望參數2是字符串,在第30行的/home/sjrem/public_html/SIT104_3/order.php中給出的資源 解析sql字符串時發生錯誤。 – David

+0

你可以把整個'$ query'一行放在這裏。 – Ergec