We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,680 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

[2 Simple Problems]php and sql db

Hello, like before, I'm still trying to make a register page with login and logout.

Here's the link to my server (If I'm not allowed to share links please remind me.)
http://fifarulez.dyndns.org/hacks4all.wapzan.com/registration/
After the registration it will give 2 warnings.

( ! ) Warning: mysql_query() [function.mysql-query]: Access denied for user ''@'localhost' (using password: NO) in C:\wamp\www\hacks4all.wapzan.com\registration\register.php on line 40

and

( ! ) Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\hacks4all.wapzan.com\registration\register.php on line 40

I tried to fix it by changing the code in:

// dbConfig.php is a file that contains your
    // database connection information. This
    // tutorial assumes a connection is made from
    // this existing file.
    include ("dbConfig.php");

by

// Replace the variable values below
    // with your specific database information.
    $host = "localhost";
    $user = "root";
    $pass = "CENSORED";
    $db = "CENDORED";
     
    // This part sets up the connection to the
    // database (so you don't need to reopen the connection
    // again on the same page).
    $ms = mysql_pconnect($host, $user, $pass);
    if ( !$ms )
    {
    echo "Error connecting to database.\n";
    }
     
    // Then you need to make sure the database you want
    // is selected.
    mysql_select_db($db);

When I do that the only thing I see is:
Error: User not added to database.

ps. I think that it's my WAMP server that isn't fully on since it's yellow, probably SQL is offline?

Thanks in advance! :)

3
Contributors
9
Replies
1 Hour
Discussion Span
1 Year Ago
Last Updated
10
Views
Question
Answered
fifarulez
Light Poster
29 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Depending on where your dbconfig file is saved, you may want to change:

include ("/dbConfig.php");

to:

include ("dbConfig.php");

If your connection to the database is rejected, it's either your include line, or your sql connect information is wrong.

stoopkid
Junior Poster in Training
90 posts since Sep 2011
Reputation Points: 17
Solved Threads: 16
Skill Endorsements: 0

seems that your problem is that you can't connect with those details, so any calls to mysql_ functions will also throw an error. Check your connection details. Try it from phpmyadmin or your favourite mysql GUI.

**If WAMP shows yellow - it probably means something bad. I use XAMPP, so I can't really comment, but do you have to manually start the mysql server? E.g. by clicking a button?

diafol
Keep Smiling
Moderator
10,849 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,539
Skill Endorsements: 61

dbConfig.php is placed with the other files but I can make it skip the problem by adding the information directly into register.php and forget the dbconfig.php

but the error after the registration still exists. I think it's WAMP.

It usually starts by itself, but I can do it manually by pressing "Start all services"
Which includes php and mysql. At the loading point it doesn't turn green, just yellow which is half the services on.

Maybe a conflicting port? I am able to access my db on another computer using my WAN ip and the port 3306.

fifarulez
Light Poster
29 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Does phpmyadmin work?

diafol
Keep Smiling
Moderator
10,849 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,539
Skill Endorsements: 61

No..


Welcome to phpMyAdmin

Error
MySQL said:

#1045 - Access denied for user 'root'@'localhost' (using password: NO)

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

fifarulez
Light Poster
29 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

OK, I'm still no better off. You're not using a PW, which I believe is the default setting anyway. root is the default username. localhost should be the default host. 3306 the default port.

Did you change any of those settings on WAMP install?

diafol
Keep Smiling
Moderator
10,849 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,539
Skill Endorsements: 61

Well, for mysql I do have a password, and the rest is localhost and root.
I left everything as it was, simply clicked next next next, done.

fifarulez
Light Poster
29 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Solved.

fifarulez
Light Poster
29 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by diafol and stoopkid

Have a look at this to change the PW:

http://www.kirupa.com/forum/showthread.php?279644-How-to-reset-password-in-WAMP-server

May be worth looking at windows task manager to see if mysql is running under processes or services tabs before you have a go at changing anything.

//EDIT

Great, mark the thread as solved (link below the edit box)

diafol
Keep Smiling
Moderator
10,849 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,539
Skill Endorsements: 61

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0849 seconds using 2.73MB