Quick help DB.PHP

moneyplox

Registered Member
Joined
Nov 18, 2012
Messages
52
Reaction score
1
Code:
<?php

    define('HOST', 'localhost');

    define('USER', '');

    define('PASS', '');

    define('DBNAME', '');

    $link = mysql_connect(HOST, USER, PASS);

    mysql_select_db(DBNAME, $link);

?>



SKYPE: I7UP37T come helpahh fella outtt?
 
Last edited by a moderator:
Well for starters, what's the problem? you should have your username/password/dbname filled otherwise the code above is just going to do nothing but throw PHP errors.

PHP:
<?php
define('HOST', 'localhost');
define('USER', 'mydbuser');
define('PASS', 'mydbpass');
define('DBNAME', 'mydb');
$link = mysql_connect(HOST, USER, PASS);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db(DBNAME, $link);
?>

There are alternative ways to initialise MySQL documented on the PHP website:


Code:
hxxp://php.net/manual/en/mysqlinfo.api.choosing.php
 
Last edited:
Back
Top