0

I recently moved a script I created for Google Maps over from my development site and I changed the information in the mysqli line and now I'm recieving an error mesage -- any idea what's going on here? Here's the error message:

Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user 'Username'@'localhost' (using password: YES) in /home/cigardig/public_html/XXXX.php on line 259

Here's the relevant code:

$mysqli = new mysqli(  "localhost", "[I]Username[/I]", "[I]Password[/I]", "[I]DB Name[/I]" );

I also don't know if this has anything to do with it but this script is using stored functions which grant as follows:

/*!50003 CREATE DEFINER=`root`@`localhost` FUNCTION `BlahBlah`(Lat1 FLOAT, Long1 FLOAT, Lat2 FLOAT, Long2 FLOAT) RETURNS float [........]
3
Contributors
10
Replies
19
Views
6 Years
Discussion Span
Last Post by diafol
Featured Replies
  • 1
    diafol 3,669   6 Years Ago

    php.net gives this example: [CODE]$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db');[/CODE] I realise you don't want to post your actual settings, but do they match this format? They seem to from your post. I think a typical default setting could be: [CODE]$mysqli = new mysqli('localhost', 'root', '', 'yourdbname');[/CODE] phpmyadmin doesn't … Read More

0

I forgot to mention in the previous post, the only thing that has changed was the username, password, and DB selected between the code. When I change it back to the old values it works but when I try the new ones it stops working again and generates the message.

0

You have changed old database credentials to new.
Check your new database's credentials proper.I think it should not be username:root for host:localhost.
Something went wrong with credentials only.

0

May very well be you SP. Can you access DB w/out SP?

I can access it through PHPmyAdmin, Remote mySQL, as well as as on other pages - is that what you're talking about?

1

php.net gives this example:

$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db');

I realise you don't want to post your actual settings, but do they match this format? They seem to from your post.

I think a typical default setting could be:

$mysqli = new mysqli('localhost', 'root', '', 'yourdbname');

phpmyadmin doesn't depend on you specifying a host, so it may be down to your host details. I assume your username and pw will be correct if you can use them to log in to phpmyadmin.

Perhaps it's the db name? Check spelling closely - no spaces. Underscores or dashes could be confused?

Votes + Comments
Solved it!
0

php.net gives this example:

$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db');

I realise you don't want to post your actual settings, but do they match this format? They seem to from your post.

I think a typical default setting could be:

$mysqli = new mysqli('localhost', 'root', '', 'yourdbname');

phpmyadmin doesn't depend on you specifying a host, so it may be down to your host details. I assume your username and pw will be correct if you can use them to log in to phpmyadmin.

Perhaps it's the db name? Check spelling closely - no spaces. Underscores or dashes could be confused?

Ugh, I feel like an idiot! I was using double quote instead of single quotes, changing that fixed and it's working beautifully now! :$

0

Hi j. I have no idea wny this should happen. I tried it with both just now and both worked file. Perhaps you had a $ or \ or something weird in one of the strings?

Anyway, something I'll look out for. Thanks.

0

Hi j. I have no idea wny this should happen. I tried it with both just now and both worked file. Perhaps you had a $ or \ or something weird in one of the strings?

Anyway, something I'll look out for. Thanks.

ardav, you are right on. I had a $ in the password and it was parsing it weird as a result :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.