Can't connect to mysql database

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Can't connect to mysql database

Postby mickeymouse » 06. April 2016 22:39

It always worked. Now it doesn't.
Mind you, I had a computer crash and had to restart to factory delivery level and restore my personal files.
Perhaps I've missed something.

I get
Fatal error: Call to undefined function mysql_connect()

mycode is:
$link = mysql_connect('localhost', $UserID, $password);
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Can't connect to mysql database

Postby Altrea » 07. April 2016 00:37

We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Can't connect to mysql database

Postby mickeymouse » 13. April 2016 01:02

Thank you Altrea
I removed the ;; saved the file and restarted Xampp butnow I get this message:
Can't use HomeAccounting:Access denied for user ''@'localhost' to database 'homeaccounting'
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Can't connect to mysql database

Postby Altrea » 13. April 2016 05:23

You got logged in by an anonymous user.
Did you define your own database user you want to use?
If yes, which host is the user allowed to login from?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Can't connect to mysql database

Postby mickeymouse » 19. February 2017 16:42

To get to my site I need to show port 1180, i.e., http://localhost:1180/homeaccounting

When my user signs-in my password check PHP file gets executed but crashes with the following message:

Warning: mysql_connect(): No connection could be made because the target machine actively refused it. in C:\xampp\htdocs\HomeAccounting\HA_LogInCheck.php on line 98
Not connected : No connection could be made because the target machine actively refused it.

Line 98 = $link = mysql_connect('localhost', $UserID, $password);

I suspect it's a port problem but can't resolve it.

Also, if I click on 'Admin' for MySQL in the XAMPP control panel I get 'Can't reach this page'
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Connection to MySql

Postby mickeymouse » 21. February 2017 15:01

When my user signs-in, my password check PHP file gets executed but crashes with the following message:

Can't use HomeAccounting:Access denied for user ''@'localhost' to database 'homeaccounting'

My code is: $link = mysql_connect('localhost', $UserID, $password);
That worked before so I don't think there is a problem with this code.

I suspect it's a port problem but can't resolve it. On the other hand, MySQL starts up OK.
(To get to my site I need to show port 1180, i.e., http://localhost:1180/homeaccounting)

Another problem, and I think related, is that if I click on 'Admin' for MySQL in the XAMPP control panel I get: 'Can't reach this page'

Thanks for your much needed help.
 
Posts: 43
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 10 Home (64 bit)
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Connection to MySql

Postby Altrea » 21. February 2017 17:06

mickeymouse wrote: Can't use HomeAccounting:Access denied for user ''@'localhost' to database 'homeaccounting'

Don't try to login with an anonymous account.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Can't connect to mysql database

Postby mickeymouse » 21. February 2017 17:53

Don't know what you mean: Don't try to login with an anonymous account.
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Can't connect to mysql database

Postby Altrea » 21. February 2017 20:01

Take a look at the message, what happened to your database username?

''@'localhost' means the same as anyuser@localhost.
Either you really didn't used a user or the user you wanted to choose has a lower priority than ''@localhost (for example root@anyhost)
This is a common issue if you change the allowed host for the user root to any (%) but leaving the default anonymous user still alive.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Can't connect to mysql database

Postby mickeymouse » 22. February 2017 00:09

Many thanks for your help.

I should have had "$Username" (which is my database user name) instead of "$UserID" (which is my web user's ID) in my following line of code.
$link = mysql_connect('localhost', $UserID, $password);
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 125 guests