Grow your CSS skills. Land your dream job.

Troubleshooting for a warning:[Web App from scratch series]

  • __
    # April 28, 2013 at 11:10 am

    > Still it keeps giving me the Connection failed error.
    `Access denied for user ‘u265831516_nick’@’localhost’ to database ‘u265831516_first’`

    Does it *always* give that error (can you *ever* connect to your DB, even in PHPMyAdmin)?

    How are you trying to create that database? Are you trying to import it using an sql file? Can you create a new table using the [Create table] button in PHPMyAdmin?

    …going back to the [script with your PDO connection](http://tinypic.com/view.php?pic=33yt2sh&s=5), try changing the line

    exit;

    to

    exit( “dsn: $dsn
    DB_USER: “.DB_USER.’
    DB_PASS: ‘.DB_PASS );

    Run the script, copy the output, and then change the script back (*do not* leave it; it’s a security risk to reveal that info to the public).

    Make sure the dsn, your username and password are correct (**do not** post your password here).

    > You sure @traq? The script causing the error is /home/u265831516/public_html/site/common/base.php, so it’s looking for /home/u265831516/public_html/site/common/inc/FirePHPCore/FirePHP.class.php unless I’m mistaken.
    @crocodillon

    sorry: yeah, I missed that. But I think Nick01 has solved that already anyway.

    # April 28, 2013 at 11:20 am

    @BenWalker Yes,It allows to create new databases.I thought of exporting the database I had creating using XAMPP,that failed too due to the same error. Then I tried the manual SQL commands as instructed in the Series. I get the same [Your text to link here…](http://tinypic.com/view.php?pic=30lj8eb&s=5 “Error”)
    @traq Sorry I missed your comment before writing this comment.I’m checking the solution posted by you.

    __
    # April 28, 2013 at 11:26 am

    Did you check your dsn string, username and password? Are they correct?

    # April 28, 2013 at 3:37 pm

    @traq
    1) Does it always give that error (can you ever connect to your DB, even PHPMyAdmin)?
    Yes,I can connect to my DB in PHPMyAdmin,but other times I am haunted by:

    Connection failed: SQLSTATE[28000] [1045] Access denied for user ‘db_user’@’localhost’ (using password: YES)

    2) How are you trying to create that database? Are you trying to import it using an sql file? Can you create a new table using the [Create table] button in PHPMyAdmin?

    Prior to your comment today, I didn’t realize I was importing a database inside database instead of tables. Do web host allow importing an entire database? Because all I can see here
    is “Create a new database option”, then your supposed to log into PHPMyadmin(where you can only import tables)

    3) I followed your step and edited my Base.php,but then this happened :
    [Warning](http://oi43.tinypic.com/34tesue.jpg “And another warning.”)
    Is my [syntax](http://oi40.tinypic.com/2koh6q.jpg “syntax”) correct ? Should the Dns field be $Linkor $Link (since all content is uploaded in site directory), either ways
    it shows the same warning.

    I really appreciarte your help.Thank you @CrocoDillon too.

    __
    # April 28, 2013 at 6:45 pm

    Your earlier warning (“`Connection failed: SQLSTATE[28000] [1045] Access denied for user ‘db_user’@’localhost’ (using password: YES)`”) was being generated in that `catch` block. When you tried my new `exit` command, we found out what the problem really was: the file which defines those constants is missing (because they were missing, an exception was thrown inside the `catch` block, which results in the fatal error you saw).

    I think you need to go back to that tutorial (and/or the github page Crocodillon linked) and make sure you *have* all of the files you actually *need*. I wouldn’t be surprised if others are missing too.

    Specifically, once you get that `inc/constants.inc.php` file in place, you need to edit it so that it defines those constants with *your* DB credentials (because they’re missing, PDO is using default values, which obviously aren’t correct).

    *****
    to answer your other questions:

    > I didn’t realize I was importing a database inside database instead of tables. Do web host allow importing an entire database? Because all I can see here is “Create a new database option”, then your supposed to log into PHPMyadmin(where you can only import tables)

    I don’t know if the file you import is trying to create tables or databases. You can open it in a text editor and just read it to find out.

    If it’s creating tables, you shouldn’t have a problem as long as you’ve already selected a DB to use in PHPMyAdmin.

    If it’s creating a new database, you might (probably will) have problems, since many shared hosts don’t allow you to create new databases programmatically (they want you to do it via your CP instead).

    > I can connect to my DB in PHPMyAdmin,but other times I am haunted by:
    Connection failed: SQLSTATE[28000] [1045] Access denied for user ‘db_user’@’localhost’ (using password: YES)

    To clarify, you sometimes get that error in PHPMyAdmin?

    # April 29, 2013 at 1:27 am

    I have updated constants.inc.php file.All the required files were present.
    I’m presented with the same error:
    Connection failed: SQLSTATE[28000] [1045] Access denied for user ‘u265831516_nick’@’localhost’ (using password: YES)

    # April 29, 2013 at 5:23 am

    By the way, change the `include_once` to `require_once` (for the constants) so you’ll get an error there if something goes wrong.

    # April 29, 2013 at 1:34 pm

    @CrocoDillon
    Same error
    Connection failed: SQLSTATE[28000] [1045] Access denied for user ‘u265831516_nick’@’localhost’ (using password: YES)

    I get a feeling it has got something to do with the privileges granted to the user of the created database?

    # May 8, 2013 at 4:58 am

    Thank you guys, the problem has been solved. I tried out a different web hosting service and figured out the MySQL host name.

Viewing 9 posts - 16 through 24 (of 24 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".