connect.inc.php global file to connect to MySQL with php

<?php
$login= "";                              // user name for you database
$pass= "";                                   // pass word to the database if you dont have a password 
						//set up leave it as ""
$database_name="";                     //name of the database

/* Don't change anything below this line                                                        */                                                   

function connect_db()
	{
	global $pass,$login;
	$db=mysql_connect("localhost",$login,$pass) or  die("Unable  to  select  database");
		
	return $db;
	
	}

function db_name()
	{
	global $database_name;
	$db_name=$database_name;
	
	return $db_name;
	
	}
?>

Then, on each file where you need MySQL connection, include:

#connect to database
include("connect.inc.php");
$db=connect_db();
$db_name=db_name();
mysql_select_db($db_name,$db);
  • info/connect.inc.php.txt
  • Dernière modification: 2018/07/18 09:45
  • par radeff