如何在PHP中使用Oracle數(shù)據(jù)庫(4)
更新時(shí)間:2006年10月09日 00:00:00 作者:
利用OCI向數(shù)據(jù)表 'email_info' 輸入數(shù)據(jù)
同上,只不過用OCI來寫
相關(guān)PHP代碼:
if ($submit == "click"){
// The submit button was clicked!
// Get the input for fullname and email then store it in the database.
PutEnv("ORACLE_SID=ORASID");
$connection = OCILogon ("username","password");
if ($connection == false){
echo OCIError($connection)."
";
exit;
}
$query = "insert into email_info values ('$fullname', '$email')";
$cursor = OCIParse ($connection, $query);
if ($cursor == false){
echo OCIError($cursor)."
";
exit;
}
$result = OCIExecute ($cursor);
if ($result == false){
echo OCIError($cursor)."
";
exit;
}
OCICommit ($connection);
OCILogoff ($connection);
}
else{
echo '
<FORM action=insert.php method=post>
請輸入姓名
<INPUT name=fullname></INPUT>
請輸入 Email 地址
<INPUT name=email></INPUT>
<INPUT name=submit type=submit value=click></INPUT>
</FORM>
';
}
?>
對了,這段腳本必須存為insert.php,因?yàn)樵谡{(diào)用的頁面中指定insert.php為表單處理程序
同上,只不過用OCI來寫
相關(guān)PHP代碼:
if ($submit == "click"){
// The submit button was clicked!
// Get the input for fullname and email then store it in the database.
PutEnv("ORACLE_SID=ORASID");
$connection = OCILogon ("username","password");
if ($connection == false){
echo OCIError($connection)."
";
exit;
}
$query = "insert into email_info values ('$fullname', '$email')";
$cursor = OCIParse ($connection, $query);
if ($cursor == false){
echo OCIError($cursor)."
";
exit;
}
$result = OCIExecute ($cursor);
if ($result == false){
echo OCIError($cursor)."
";
exit;
}
OCICommit ($connection);
OCILogoff ($connection);
}
else{
echo '
<FORM action=insert.php method=post>
請輸入姓名
<INPUT name=fullname></INPUT>
請輸入 Email 地址
<INPUT name=email></INPUT>
<INPUT name=submit type=submit value=click></INPUT>
</FORM>
';
}
?>
對了,這段腳本必須存為insert.php,因?yàn)樵谡{(diào)用的頁面中指定insert.php為表單處理程序
您可能感興趣的文章:
- PHP下的Oracle客戶端擴(kuò)展(OCI8)安裝教程
- Win7 64位系統(tǒng)下PHP連接Oracle數(shù)據(jù)庫
- windwos下使用php連接oracle數(shù)據(jù)庫的過程分享
- thinkphp中連接oracle時(shí)封裝方法無法用的解決辦法
- 一個(gè)php導(dǎo)出oracle庫的php代碼
- 用PHP調(diào)用Oracle存儲過程的方法
- 如何在PHP中使用Oracle數(shù)據(jù)庫(6)
- 如何在PHP中使用Oracle數(shù)據(jù)庫(5)
- 如何在PHP中使用Oracle數(shù)據(jù)庫(3)
- 如何在PHP中使用Oracle數(shù)據(jù)庫(1)
- 操作Oracle的php類
- php+oracle 分頁類
- 一個(gè)oracle+PHP的查詢的例子
- PHP處理Oracle的CLOB實(shí)例
相關(guān)文章
PHP輸出控制功能在簡繁體轉(zhuǎn)換中的應(yīng)用
PHP輸出控制功能在簡繁體轉(zhuǎn)換中的應(yīng)用...2006-10-10如何將數(shù)據(jù)從文本導(dǎo)入到mysql
如何將數(shù)據(jù)從文本導(dǎo)入到mysql...2006-10-10在 PHP 中使用隨機(jī)數(shù)的三個(gè)步驟
在 PHP 中使用隨機(jī)數(shù)的三個(gè)步驟...2006-10-10