| Current Path : /var/www/html/mmishra/iws8/html/pcstore/backupxxxxxxx/ |
| Current File : /var/www/html/mmishra/iws8/html/pcstore/backupxxxxxxx/pcstore_dbconnect.inc |
<?php
$dbhost = 'localhost';
$dbusername = 'root';
$dbuserpassword = 'mysql';
$default_dbname = 'pcstore';
$MYSQL_ERRNO = '';
$MYSQL_ERROR = '';
function db_connect($dbname=''){
global $dbhost, $dbusername, $dbuserpassword, $default_dbname;
global $MYSQL_ERRNO, $MYSQL_ERROR;
$con = mysql_connect($dbhost, $dbusername, $dbuserpassword);
if(!$con){
$MYSQL_ERRNO = 0;
$MYSQL_ERROR = "connection failed to the host $dbhost.";
return 0;
}
else if(empty($default_dbname) && !mysql_select_db($default_dbname)){
$MYSQL_ERRNO = mysql_errno();
$MYSQL_ERROR = mysql_error();
return 0;
}
else if(empty($dbname) && !mysql_select_db($dbname)){
$MYSQL_ERRNO = mysql_errno();
$MYSQL_ERROR = mysql_error();
return 0;
}
else {
mysql_select_db($dbname);
//echo $con;
return $con;
}
}
function sql_error(){
global $MYSQL_ERRNO, $MYSQL_ERROR;
if (empty($MYSQL_ERROR)){
$MYSQL_ERRNO = mysql_errno();
$MYSQL_ERROR = mysql_error();
}
return "$MYSQL_ERRNO: $MYSQL_ERROR";
}
error_reporting(0);
$con = db_connect('pcstore');
if(!$con) die(sql_error());
?>