Pavlin24 Posted August 21, 2013 Share Posted August 21, 2013 (edited) Hallo, I need some help again. Today I tried to create a data base with MySQL. Here is the code: <?php$con=mysqli_connect("pavlin-angelov.com","pavlin24","abc123");// Check connectionif (mysqli_connect_errno()) //ако има грешка при свързването { echo "Failed to connect to MySQL: " . mysqli_connect_error(); //показва грешката }// Create database$sql="CREATE DATABASE my_db";if (mysqli_query($con,$sql)) { echo "Database my_db created successfully"; }else { echo "Error creating database: " . mysqli_error($con); }?> And here is the error message: Fatal error: Call to undefined function mysqli_connect() in /home/pavlinan/public_html/create_db.php on line 2 What might be the reason for this? Edited August 21, 2013 by Pavlin24 Link to comment Share on other sites More sharing options...
justsomeguy Posted August 21, 2013 Share Posted August 21, 2013 Your installation of PHP does not have the mysqli extension installed or enabled. Link to comment Share on other sites More sharing options...
Pavlin24 Posted August 22, 2013 Author Share Posted August 22, 2013 thank you Link to comment Share on other sites More sharing options...
Pavlin24 Posted October 7, 2013 Author Share Posted October 7, 2013 Hi again. I could not manage with this problem. So I decided to try this on my PC using XAMPP. But here appeared problem again. This is the error message: "Warning: mysqli_connect(): (HY000/1045): Access denied for user 'pavlin24'@'localhost' (using password: YES) in C:xampphtdocscreate_db.php on line 2Failed to connect to MySQL: Access denied for user 'pavlin24'@'localhost' (using password: YES)Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in C:xampphtdocscreate_db.php on line 11Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in C:xampphtdocscreate_db.php on line 17Error creating database:" And here is the code: <?php$con=mysqli_connect("localhost","pavlin24","123");// Check connectionif (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); }// Create database$sql="CREATE DATABASE my_db";if (mysqli_query($con,$sql)) { echo "Database my_db created successfully"; }else { echo "Error creating database: " . mysqli_error($con); }?> What might be the problem? Link to comment Share on other sites More sharing options...
thescientist Posted October 7, 2013 Share Posted October 7, 2013 look at the error messages, it should be obvious "Warning: mysqli_connect(): (HY000/1045): Access denied for user 'pavlin24'@'localhost' (using password: YES) in C:xampphtdocscreate_db.php on line 2Failed to connect to MySQL: Access denied for user 'pavlin24'@'localhost' (using password: YES) does a user pavlin24 with password 123 actually have permissions to your localhost database? That is where I would start investigating first. How did you add this user? using phpMyAdmin? Link to comment Share on other sites More sharing options...
Pavlin24 Posted October 7, 2013 Author Share Posted October 7, 2013 I am not using phpMyAdmin. Now I use this user for first time. Must I define it somewhere first? Link to comment Share on other sites More sharing options...
Pavlin24 Posted October 7, 2013 Author Share Posted October 7, 2013 Yes. Thank you. I found the user defined in the documentation. And now it works. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now