ok so if i put it all in a function say
function dbconnect()
i would have to do
require 'protected/db_connect.php';
dbconnect()
on any page that i need to connect to the database right?
ok so i made the change and i get these errors now:
Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 113 in /home/frostbit/public_html/php/protected/db_connect.php on line 12
Fatal error: Call to undefined function iserror() in /home/frostbit/public_html/php/protected/db_connect.php on line 13
Code:
<?php
$db_engine = 'mysql';
$db_user = 'admin';
$db_pass = '**';
$db_host = 'localhost';
$db_name = '**';
$datasource = $db_engine.'://'.
$db_user.':'.
$db_pass.'@'.
$db_host.'/'.
$db_name;
$db_object = mysql_connect($datasource, TRUE);
if(DB::isError($db_object)) {
die($db_object->getMessage());
}
$db_object->setFetchMode(DB_FETCHMODE_ASSOC);
include('check_login.php');
?>
i see what i am doing wrong, i reread the tutorial and i am missing something important: require_once 'DB.php';
Edit:
ok ive changed my pace and i tried byron's tutorial this is my code:
Code:
<?php
$username = "frostbit_admin";
$password = "**";
$server = "localhost";
$database="frostbit_members";
$mysqlconnection = mysql_connect($server, $username, $password);
if (!$mysqlconnection) {
die('There was a problem connecting to the mysql server. Error returned: '. mysql_error());
}
$databaseconnection = mysql_select_db($database);
if (!$databaseconnection) {
die('There was a problem using that mysql database. Error returned: '. mysql_error());
}
?>
it pretty much works but i am getting denied access to the local host even though i set up the mySQL database through cpanel