Page 1 of 1

Can't connect to mysql database

PostPosted: 06. April 2016 22:39
by mickeymouse
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);

Re: Can't connect to mysql database

PostPosted: 07. April 2016 00:37
by Altrea

Re: Can't connect to mysql database

PostPosted: 13. April 2016 01:02
by mickeymouse
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'

Re: Can't connect to mysql database

PostPosted: 13. April 2016 05:23
by Altrea
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?

Re: Can't connect to mysql database

PostPosted: 19. February 2017 16:42
by mickeymouse
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'

Connection to MySql

PostPosted: 21. February 2017 15:01
by mickeymouse
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)

Re: Connection to MySql

PostPosted: 21. February 2017 17:06
by Altrea
mickeymouse wrote: Can't use HomeAccounting:Access denied for user ''@'localhost' to database 'homeaccounting'

Don't try to login with an anonymous account.

Re: Can't connect to mysql database

PostPosted: 21. February 2017 17:53
by mickeymouse
Don't know what you mean: Don't try to login with an anonymous account.

Re: Can't connect to mysql database

PostPosted: 21. February 2017 20:01
by Altrea
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.

Re: Can't connect to mysql database

PostPosted: 22. February 2017 00:09
by mickeymouse
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);