Jump to content

data base creating- fatal error


Pavlin24

Recommended Posts

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 by Pavlin24
Link to comment
Share on other sites

  • 1 month later...

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...