当前位置: 首页 > 图文教程 > 网络编程 > PHP > 如何在PHP中使用Oracle数据库(4)

PHP
图书管理程序(三)
PHP脚本的10个技巧(1)
PHP脚本的10个技巧(2)
用PHP调用数据库的存贮过程!
给多个地址发邮件的类
用函数读出数据表内容放入二维数组
用文本文件制作留言板提示(上)
用文本文件制作留言板提示(下)
WIN98下Apache1.3.14+PHP4.0.4的安装
Email+URL的判断和自动转换函数
一个高ai的分页函数和一个url函数
PHP的ASP防火墙
PHP网上调查系统
转换中文日期的PHP程序
全文搜索和替换
教你如何把一篇文章按要求分段
一个用于mysql的数据库抽象层函数库
php&java(三)
php&java(一)
php&java(二)

如何在PHP中使用Oracle数据库(4)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 75 ::
收藏到网摘: n/a

利用OCI向数据表 'email_info' 输入数据
同上,只不过用OCI来写
相关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,因为在调用的页面中指定insert.php为表单处理程序