MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 7th, 2004, 04:29 PM
flashy3 flashy3 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 flashy3 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post Can't login to Mysql with password via PHP

Hi, I am pretty new to MySQL and PHP.

I am running Mysql 5.0 and Php 4.3.4 on Win 2000.

I am also using Apache as my Web Server.

I have been able to establish connectivity to mysql
using various commands.

mysql -u root -p

this prompts me for a password and I can login once the correct password is entered.

i can also still do:
mysql
by itself and that will log me in as a ODBC/blank user (is this secure?)

I created a new user in mysql control center and gave it global privs and a password.

and i am also able to execute
mysql -u newuser -p
and this all works.

Now I go to the php side of things
and try to execute
mysql_connect(localhost,"newuser","password") or die("unable to connect");
and all I get is unable to connect.

Unless I change the password on this new user to NULL ie ""
If I do this in php it connects and allows me to select the write database and select from some tables. Now I have also tried this as the root user and I receive the same "unable to connect" message from php.

Any ideas of why it won't accept a password when trying to connect? I am too new to know if I have set something up correctly.

Thanks for any help.

Reply With Quote
  #2  
Old February 9th, 2004, 09:11 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
you need to put quotes around the localhost, as the host should be passed as a string.

For example:
PHP Code:
 mysql_connect("localhost","newuser","password") or die("unable to connect"); 

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Can't login to Mysql with password via PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT