包含phpociexecute的词条
本文目录一览:
- 1、PHP如何连接oracle数据库
- 2、还是那个php问题
- 3、php怎么始终连接不上ORACLE啊,有谁能帮帮我啊,phpinfo也显示支持oci8,oracle版本为9.2.0.1.0
- 4、求PHP与ORACLE数据库连接的代码
- 5、请问PHP如何取数据库中sequence的nextval值到一个变量?
PHP如何连接oracle数据库
首先你要在php.ini文件中找到
extension=php_oci8.dll 前面的注释符号“;”去掉,使php能够加载支持oracle的模块;
下面的代码是调试通过的,可直接使用的:
html
body
?php
$dbconn=OCILogon("root","pass","(DESCRIPTION=(ADDRESS=(PROTOCOL =TCP)(HOST=远程IP)(PORT = 1521))(CONNECT_DATA =(SID=GZXNCW)))");
if($dbconn!=false)
{
echo "连接成功";
if(OCILogOff($dbconn)==true)
{
echo "关闭连接成功!";
}
}
else
{
echo "连接失败";
}
?
/body
/html
?php
$dbconn=oci_connect("你的账号","你的密码","你的数据库名称");//请把中文件设置为你的值;
$stmt=oci_parse($dbconn, "select * from scott.hallo");
oci_execute($stmt, OCI_DEFAULT);
echo $conn."----selecting\n\n";
while (oci_fetch($stmt))
{
echo ($conn."[".oci_result($stmt, "TEST")."]\n\n");
}
echo ($conn . "----done\n\n");
?
还是那个php问题
你其他程序可以运行成功? ,我过会运行下试试,等等
错误在这里:
“select sum(qty_stock*unit_cost) from Part;“
执行语句结尾不能像mysql那样写,以”;“来执行多条语句
应该去掉”;“:“select sum(qty_stock*unit_cost) from Part“
建议:
你使用的oci函数最好改为最新的名字就,以下来自php手册
ocilogoff — 别名 oci_close()
Report a bug
reject note 说明
Warning
自 PHP 5.4.0 起,已经废弃此别名。强烈建议不要应用此别名 。
php怎么始终连接不上ORACLE啊,有谁能帮帮我啊,phpinfo也显示支持oci8,oracle版本为9.2.0.1.0
我曾经装过10G的php连接ord。
程序运行必须步骤如下
1.安装orl client
2.修改php.ini,打开php_oci.dll等扩展dll
extension=php_pdo_oci.dll
extension=php_pdo_oci8.dll
extension=php_oci8.dll
extension=php_oracle.dll
?php
@header("Content-Type: text/html; charset=gb2312");
$conn = oci_connect('name', 'pass', 'ordclientdbname','ZHS16GBK');//SIMPLIFIED CHINESE_CHINA.ZHS16GBK AMERICAN.UTF8
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
exit;
}
$query = 'SELECT * FROM taobaogoods';
$stid = oci_parse($conn, $query);
if (!$stid) {
$e = oci_error($conn);
print htmlentities($e['message']);
exit;
}
$r = oci_execute($stid, OCI_DEFAULT);
if(!$r) {
$e = oci_error($stid);
echo htmlentities($e['message']);
exit;
}
print 'htmlmeta http-equiv="Content-Type" content="text/html; charset=gb2312"bodytable border="1"';
$i =0;
while($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) {
print 'tr';
foreach($row as $item) {
// if($i ==3)echo "script alert('$item');/script";
print 'td'.($item ? $item:' ').'/td';
//print 'td'.($item ? iconv('utf-8','gb2312',htmlentities($item)):' ').'/td';
}
$i++;
//exit;
print '/tr';
}
print '/table/body/html';
oci_close($conn);
exit;
求PHP与ORACLE数据库连接的代码
强烈推荐使用ADODB库链接数据库。
如果一定要使用PHP内置函数,那么:
如果PHP版本5.0,那么使用下面的函数
oci_connect
(
username,
password
,
dbname
)
例子:
?php
$conn
=
oci_connect('hr',
'hr',
'orcl');
//
建立连接
if
(!$conn)
{
$e
=
oci_error();
htmlentities($e['message']);
exit;
}
$query
=
'SELECT
*
FROM
DEPARTMENTS';
//
查询语句
$stid
=
oci_parse($conn,
$query);
//
配置SQL语句,准备执行
if
(!$stid)
{
$e
=
oci_error($conn);
htmlentities($e['message']);
exit;
}
$r
=
oci_execute($stid,
OCI_DEFAULT);
//
执行SQL。OCI_DEFAULT表示不要自动commit
if(!$r)
{
$e
=
oci_error($stid);
echo
htmlentities($e['message']);
exit;
}
//
打印执行结果
'table
border="1"';
while($row
=
oci_fetch_array($stid,
OCI_RETURN_NULLS))
{
'tr';
foreach($row
as
$item)
{
'td'.($item?htmlentities($item):' ').'/td';
}
'/tr';
}
'/table';
oci_close($conn);
?
请问PHP如何取数据库中sequence的nextval值到一个变量?
$cx="select seq_id.nextval as seq from dual";
$conn-query($cx);
while($conn-next_record()){
$seq_id=$conn-f("seq");
}
版权声明
本文仅代表作者观点,不代表Code前端网立场。
本文系作者Code前端网发表,如需转载,请注明页面地址。
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。