Problem Trying To Connect To My Database - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Problem Trying To Connect To My Database (1213 Views)
| Problem Trying To Connect To My Database by seunzone(op): 11:01pm On Oct 24, 2016 |
holla. Please if you're quite handy with PHP help out. see this code //create database $connection = mysqli_connect("localhost","root","" ;if (!$connection){ die("Database connection failed: " . mysql_error()); } //databas select code $db_select = mysqli_select_db("alm",$connection); if (!$db_select){ die("Database connection failed: " .mysql_error()); } ?> Its a php file, l'm trying to connect to a database named alm. my localhost password is null so thats not the problem. My browser gives the following error; Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in C:\wamp\www\alimi\databases.php on line 8 Database connection failed: |
| Re: Problem Trying To Connect To My Database by Nobody: 11:06pm On Oct 24, 2016 |
Can solve it for a fee |
| Re: Problem Trying To Connect To My Database by noordean(m): 11:27pm On Oct 24, 2016 |
seunzone:The order of ur arguments to mysqli_select_db() is wrong. $connection should come before db name. should be: mysqli_select_db($connection,"alm" ![]() It's shown clearly from the error msg. |
| Re: Problem Trying To Connect To My Database by ANTONINEUTRON(m): 12:04am On Oct 25, 2016 |
Forget That Mysqli_select_db() i.e cancel it. and use only $CONNECTION = mysqli_connect("host","username","password","databasename" ;
i.e ur database name is within the mysqli_connect() |
| Re: Problem Trying To Connect To My Database by Whytelyon(m): 6:41am On Oct 25, 2016 |
In this order.
|
| Re: Problem Trying To Connect To My Database by noordean(m): 7:23am On Oct 25, 2016 |
ANTONINEUTRON:It can be outside. it depends on what he's trying to achieve. |
| Re: Problem Trying To Connect To My Database by guru01(m): 7:56am On Oct 25, 2016 |
Noordean is right, mysqli resource is suppose to be the first parameter pass, while the other is dbname. |
| Re: Problem Trying To Connect To My Database by paranorman(m): 11:30am On Oct 25, 2016 |
The mighty PDO.. . ![]() |
| Re: Problem Trying To Connect To My Database by ANTONINEUTRON(m): 7:31pm On Oct 25, 2016 |
noordean:yea the 'USE' command i think ?? |
| Re: Problem Trying To Connect To My Database by ANTONINEUTRON(m): 7:31pm On Oct 25, 2016 |
noordean:yea the 'USE' command i think ?? |
| Re: Problem Trying To Connect To My Database by ANTONINEUTRON(m): 7:31pm On Oct 25, 2016 |
noordean:yea the 'USE' command i think ?? |
I Need To Deal With My Database. • GURUS! I Need Urgent Help With Using Php To Connect To Xampp Mysql • Please How Do I Print This Data From MY Database. MYSQL, PHP • 2 • 3 • 4
Help Someone Is Trying To Hack My Wordpress Site • Customized Mobile App That Controls A Solar Inverter • Google Adsense Secrets Revealed
;

??