I am using SQLplus and zend server. When I try to run config.php, I get the error. I dont know whats causing it. This the code of config.php
<?php
$host="jojo"; // Host name
$username="system"; // Mysql username
$password="a1234"; // Mysql password
$db_name="project_db1"; // Database name
//Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select DB");
?>
I tried to replace the above code and made connection using the following code:
$conn= oci_connect("system" , "a1234" , "(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = jojo)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcale)
)
)");
The connection problem was solved but now
mysql_select_db("$db_name")or die("cannot select DB");
this line of code is giving the same error, i.e "connection cannot be made target machine actively refused it". I dont understand what the problem is. Why it is not connecting using mysql_connect.
oci_connect is a different API - its for ORACLE databases and mysql_connect is for MYSQL databases. I think you're mixing up quite a few things here, additionally : you forgot both the port and the database in mysql_connect.
you need to use these functions exclusively : http://php.net/manual/en/ref.oci8.php