FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!

Connecting php to a mysql server with mysqli




To connect to a database using mysqli, you can do it
Code:

$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_errno) {
    echo "can´t connect to MySql: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
echo $mysqli->host_info . "\n";
///With port:
$mysqli = new mysqli("IP", "user", "password", "database", 3306);
if ($mysqli->connect_errno) {
    echo "can´t connect to MySql: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

the second case is if you want to connect to a ip, with a open port.



0 blog comments below




FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.