Jump to content

why do my database name is not updated even after update of the file.


Recommended Posts

i restarted a database and updated my db connection file which connect to the database but for some reason i get this error: Fatal error: Uncaught mysqli_sql_exception: Unknown database 'phplogin' in C:\xampp2\htdocs\container\phplogin\registration\connect_db2.php:8 Stack trace: #0.

i emptied my cookies from any time and it still doesnt update. it is reading the old database name, the one i lost after uninstalling but i did not made the erase of the htdocs folder. i dont know if it might be a problem but the new xamp is installed in another folder in the same directory so i wonder if it might be the issue.. apart of that i know for sure that the database exist and the name is spelled right so this isnt the issue here.

7 minutes ago, gw1500se said:

You need to show your code but off hand I would say that there is no database named 'phplogin'. I'm guessing that is a table name and the database itself is named something else.

as i said phplogin was the name of the previous database from before i uninstalled xamp because i had locked my root user account...

the name is updated to my actual db name in my databse connection file that i use on every pages so it should normally work but it isnt ..

47 minutes ago, ginerjm said:

Have you run some sql to list out the databases that ARE defined?  Is this the only database name that you are missing?  Try "Show Databases".

i completely started over in a new folder after uninstalling so unless there is something in the config that have stayed the same as before and is defining my variable DATABASE_NAME  as my previous database name, i dont see what could do that.. 

$DATABASE_HOST = 'localhost';
$DATABASE_USER = 'root';
$DATABASE_PASS = '';
$DATABASE_NAME = '';
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);

if (mysqli_connect_errno()) {
	// If there is an error with the connection, stop the script and display the error.//
	exit('Failed to connect to MySQL: ' . mysqli_connect_error());
}
?>

this is my db connection file everything was working fine before i messed up my database and now it is acting as if there was cookies keeping this wrong name 

1 hour ago, gw1500se said:

Then it must be a permissions issue resulting from the change. Check the httpd/error log.

sorry but i never heard of http/error log is this something i am capturing with this error code in the file above?

i guess the error log that gets the closest to your definition seems like this :

[Mon Oct 31 11:09:58.158903 2022] [ssl:warn] [pid 16932:tid 420] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Oct 31 11:09:58.483892 2022] [ssl:warn] [pid 16932:tid 420] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Oct 31 11:09:58.738894 2022] [mpm_winnt:notice] [pid 16932:tid 420] AH00354: Child: Starting 150 worker threads.
[Mon Oct 31 12:09:02.998050 2022] [php:error] [pid 16932:tid 1908] [client ::1:61307] PHP Fatal error:  Uncaught mysqli_sql_exception: Access denied for user 'root'@'localhost' (using password: YES) in C:\\xampp2\\htdocs\\container\\phplogin\\registration\\connect_db2.php:8\nStack trace:\n#0 C:\\xampp2\\htdocs\\container\\phplogin\\registration\\connect_db2.php(8): mysqli_connect('localhost', 'root', '', 'phplogin')\n#1 C:\\xampp2\\htdocs\\container\\phplogin\\registration\\register.php(3): include('C:\\\\xampp2\\\\htdoc...')\n#2 {main}\n  thrown in C:\\xampp2\\htdocs\\container\\phplogin\\registration\\connect_db2.php on line 8, referer: http://localhost/container/phplogin/registration/register.html

 

1 hour ago, ginerjm said:

So since you did not do as I asked I'm guessing that the issue is not a 'missing dbname' but rather your db connection.  I thought it was something else.

the problem doesnt seem to come from the name but effectively from the connection,  just as if the server was trying to connect to the new database with the previous name kept in cache or something, because the name i put in DATABASE_NAME is the correct and the database exist i just created it but couldnt register the first user using my register page. so i changed the connection file to the right database info but it never changed anything.

1 hour ago, gw1500se said:

Yep. There you go. It is a permissions error or wrong password for root or root is the wrong MySQL user for that database.

would it be posible that since i did not delete the previous database htdocs folder and since i am using the same user login info it might interfere between the two instances ?

I am not following you.    Can you make a connection or not?  And if you can make that connection can you run the simple query I asked for to tell me what database names you DO HAVE?  A simple yes or no could be all you have to say here, and not repeat my whole post

i honestly dont know where you want me to do this query.. i am connected on phpmyadmin and i can do whatever i want but when it comes to connect via php this is where it is using the previous database name for no reason apparently. and i jut did the query in the sql section and it is showing my actual database.

Edited by alexandre

If you have phpadmin then simplyy run the query I gave you right there.  Simply type in 'show databases' in phpadmin's query window and let's see if your 'missing' database name is present.

So is your 'missing' database name there???? And what are the "default" ones?    My host has only one 'default' db named "information_schema".  I am curious what other default ones you have.

Edited by ginerjm
27 minutes ago, ginerjm said:

If you have phpadmin then simplyy run the query I gave you right there.  Simply type in 'show databases' in phpadmin's query window and let's see if your 'missing' database name is present.

i am so stupid sometimes .... i simply didnt reopened the new folder in my workspace so i was updating the old files ....

and thank you for your devotiuon , i appreciate.

Edited by alexandre
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.