Hey,
I am a newbie to php programming i need help with database connectivity, i need to use a single file which will contain database connection in all other pages. Is there any example ?
What i am trying to do is
with this I can establish the connection.
Now I try to use this in other php page by using "include" command.
It is not working can anybody tell me what am I doing wrong?
PS: how to close the connection in new file or I don't need to handle it.
I am a newbie to php programming i need help with database connectivity, i need to use a single file which will contain database connection in all other pages. Is there any example ?
What i am trying to do is
PHP:
<?php
$sql_host = 'localhost';
$sql_user = 'root';
$sql_pass = '';
$err_msg = "Error occured";
$sql_db = 'alumni portal';
if(!@mysql_connect($sql_host,$sql_user,$sql_pass) || !@mysql_select_db($sql_db)){
echo $err_msg;
}
?>
with this I can establish the connection.
Now I try to use this in other php page by using "include" command.
It is not working can anybody tell me what am I doing wrong?
PS: how to close the connection in new file or I don't need to handle it.