Log in

View Full Version : Connect php to mysql from apache server


Dany123
Feb 20, 2013, 06:26 AM
please can someone help to figure these things out. I wrote these codes to connect to my database but it is not connecting even when I assume that is connected to the database but it is not responding that is connected, this is the code

<?php
// connecting to Database
$db_server = 'localhost:3306';
$db_user = 'root';
$db_password = 'password';

$db_mysql_connect($db_server,$db_user,$db_password ) or die (' The connect could not be established');
$db_check = mysql_select_db ($db_name);
if (db)
echo 'connect to Database established';
?>

and this is the responds:-

Fatal error: Function name must be a string in C:\xampp\htdocs\connectionfile.php on line 7

but I can not figure it out.

ericlewis
Mar 5, 2013, 04:48 AM
hey Deny try the below code

<?php

$db_host = "localhost";
$db_name = "YOUR DB NAME";
$db_user = "root";
$db_pass = "password";

$con = mysql_connect($db_host,$db_user,$db_pass);

if($con){

}


?>

ericlewis
Mar 5, 2013, 04:49 AM
If($con){
Mysql_select_db($db_name,$con);
}