woodsonoversoul Posted June 21, 2007 Share Posted June 21, 2007 are you required to include a password if your db dosen't require it? My connection was working fine using: // set server access variables $host = "localhost"; $user = "root"; $db = "testdb"; // open connection $connection = mysql_connect($host, $user) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); But when I try to do this using mysqli: // set server access variables $host = "localhost"; $user = "root"; $db = "testdb"; // create mysqli object // open connection $mysqli = new mysqli($host, $user, $db); // check for connection errors if (mysqli_connect_errno()) { die("Unable to connect!"); I get an error message. What gives? Quote Link to comment https://forums.phpfreaks.com/topic/56562-solved-connecting-to-a-database-using-mysqli/ Share on other sites More sharing options...
trq Posted June 21, 2007 Share Posted June 21, 2007 You'll need to provide an empty password perameter. mysqli is getting confused because it expects the third argument to be the password. $mysqli = new mysqli($host, $user, "", $db); Quote Link to comment https://forums.phpfreaks.com/topic/56562-solved-connecting-to-a-database-using-mysqli/#findComment-279362 Share on other sites More sharing options...
woodsonoversoul Posted June 22, 2007 Author Share Posted June 22, 2007 Thanks, that totally solved my problem Quote Link to comment https://forums.phpfreaks.com/topic/56562-solved-connecting-to-a-database-using-mysqli/#findComment-279668 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.