Couldn't select database.

Codes here !

Moderators: egami, macek, gesf

Post Reply
AttilaJamilov
New php-forum User
New php-forum User
Posts: 1
Joined: Fri Jul 21, 2017 1:16 pm

Fri Jul 21, 2017 1:29 pm

Hi! I was making my websites register page and my connect.php file is not working, and I can't select the database. Here is the code. Thank you for help!

Code: Select all

<?php
$conn = mysqli_connect(example-database);

if(!$conn) {
	die('Could not connect'.mysqli_error() );
}

$db_selected = mysqli_select_db("example-database");
if(!$db_selected) {
	die( 'Could not select database' .mysqli_error() );
}
?>
Thank you,
Attila J.

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 728
Joined: Mon Feb 22, 2016 5:52 pm

Fri Jul 21, 2017 5:08 pm

You haven't got enough parameters. What made you think this would work?

You'd be better off learning PDO rather than mysqli as it was only intended to be used as a transitional interface. PDO imo is easier to understand and learn.

Post Reply