LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 02-18-2005, 04:30 AM   #1
opsraja
Member
 
Registered: Sep 2004
Posts: 37

Rep: Reputation: 15
connecting to MYSQL remote database


I have 3 different hosts. One host contains a mysql database and the other 2 hosts (are supposed to anyway) connect to the database remotely. However, only one of them does. The other one does not. It just spits out an error at me. Here is the code I am using to connect. It is identical on both machines which leads me to believe that I have to do something to the host machine, (or maybe something iptables related? i'm not sure). Does anyone know how to fix this? TIA.

<?
// hostname or ip of server
$servername='**********';

// username and password to log onto db server
$dbusername='*********';
$dbpassword='********';

// name of database
$dbname='*********';

////////////// Do not edit below/////////

connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
?>
 
Old 02-18-2005, 06:52 AM   #2
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
Let me know if this tutorial works. I haven't tried it but it looks like it would do the job.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
connecting to a MySQL database hsa Linux - General 3 09-16-2005 07:34 AM
probs with connecting to mysql database using php ankscorek Linux - Software 4 08-16-2005 08:40 PM
MySQL and remote database inspleak Linux - Networking 3 09-17-2004 02:00 AM
connecting to remote MySQL server acos7 Linux - Software 2 01-31-2004 12:37 AM
Connecting Mysql Database on remote server akamol Programming 4 10-16-2003 12:46 PM


All times are GMT -5. The time now is 11:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration