如何使用xampp在php中连接Oracle数据库?
对吗?
$servername = "localhost";
$username= "username";
$password= "password";
$dbname = "db";
$conn= new mysqli($servername,$username,$password,$dbname);
// check connection
if($conn->connect_error){
die("connection Failed:".$conn->connection_error);
}
答案 0 :(得分:2)
尝试一下
查看$ HOME / public_html / connect.php中的代码
<?php
// Create connection to Oracle
$conn = oci_connect("phphol", "welcome", "//localhost/orcl");
if (!$conn) {
$m = oci_error();
echo $m['message'], "\n";
exit;
}
else {
print "Connected to Oracle!";
}
// Close the Oracle connection
oci_close($conn);
?>
oci_connect()函数包含用户名,密码和连接字符串。在这种情况下,将使用Oracle的Easy Connect连接字符串语法。它由主机名和数据库服务名组成。
oci_close()函数关闭连接。脚本结束后,所有未明确关闭的标准连接都会自动释放。
答案 1 :(得分:1)
$username="OE";
$password="OE";
$db="(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)";
$connection = oci_connect($username, $password, $db);
if (!$connection) {
$e = oci_error();
echo htmlentities($e["message"]);
}
答案 2 :(得分:-1)
尝试使用此功能发出查询请求
mysqli_query($ connectionhandler,$ sqlquery);