PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 2nd, 2002, 08:33 PM
tonyk tonyk is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 tonyk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Connecting to MySQL on a different server

I'm working with a PHP/MySQL shopping application (oscommerce) and I am running the application with Database on one server (server1.com) and would like to run the admin and checkout portions of the application on a second secure server (server2.com).

I am able to reference the MySQL database on one server from the secure server using PHP and a standard connection method:

//Connecting to the database
$con = mysql_connect("server1.comort","testuser","password") or die ("Couldn't connect to server");

//Specifying the database
$db = mysql_select_db("database", $con) or die ("Couldn't connect to database");

But I get the following error, when it tries to authenticate the user:

Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; T312461)
Warning: MySQL Connection Failed: Access denied for user: 'testuser@server2.com' (Using password: YES) in /usr/local/htdocs/lakeview/test1.php on line 14
Couldn't connect to server

Rather than trying to log testuser into MySQL on server1.com, it is trying to login testuser@server2.com...who is obviously not a valid user for that database on server1.com.

Is there anyway to prevent PHP from passing testuser@server2.com as the login user? I just need to be able to login testuser with not @ or identification of the server the request is originating from.

Thanks in advance for any advice on how to do this.

Reply With Quote
  #2  
Old September 2nd, 2002, 09:02 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: Connecting to MySQL on a different server

What is happening is by design...the portion after the @ is the host you are connecting from. What you need to do is add a use in your database that corresponds to the user@hostname combo....

Reply With Quote
  #3  
Old September 2nd, 2002, 09:03 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: Connecting to MySQL on a different server

Try passing:

mysql_connect($server, user@server1.com, $pass);

Otherwise, log on to the MySQL server and set the username to be test@% - this will allow any host and should resolve the problem.

Have you ensured your password is correct as well - I only ask because the error resmbles the error you get with an incorrect password.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Connecting to MySQL on a different server


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 3 hosted by Hostway