[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Website files and database linking on different servers

Posted on 2013-05-14
11
Medium Priority
?
316 Views
Last Modified: 2013-06-06
I have a website all set up and working using MySQL.

My client now want the website hosted on their own servers. However it's a bit of a game to get database's set up there so I want to keep the database on my server but move the website files to his server.

Until now I have only ever connected a website with a database on the same server using the Dreamweaver created connection script like this...

# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_iafl = "localhost";
$database_iafl = "database";
$username_iafl = "username";
$password_iafl = "password";
$iafl = mysql_pconnect($hostname_iafl, $username_iafl, $password_iafl) or trigger_error(mysql_error(),E_USER_ERROR); 

Open in new window



How would I edit this to link to another server? I have tried changing 'localhost' to the ip address but that didn't work?
0
Comment
Question by:BrighteyesDesign
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +1
11 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39165876
Allow incoming connections in your firewall for port 3306.  You also have to make sure that the user is allowed to connect remotely.  It is common practice to create the user twice with the same password but different connections, 'localhost' and '%' (anyhost).  If you have phpMyAdmin on your machine, this is very easy.  You can copy a user and just change the connection.

http://dev.mysql.com/doc/refman/5.1/en/adding-users.html
0
 
LVL 44

Expert Comment

by:Chris Stanyon
ID: 39165924
You'll also need to change the hostname to your IP address, as it won't be localhost any more!

$hostname_iafl = "123.456.789.012";
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39168047
This is only tangentially related, but you'll also need to get off of MySQL because PHP is removing support for the MySQL extension. This article tells what you must do and why.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html

Best to all, ~Ray
0
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:BrighteyesDesign
ID: 39168183
ffs, so i'm stressing here with timescales and paying the bills and I now have to change 85 websites so the support MySQLi?

I guess all will be ok until my hosts decide to intall the latest PHP?

Thanks for the heads up though Ray...
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39168279
You'll probably get DEPRECATED messages before everything falls apart.  But if you're not expecting the messages, it can get nasty - especially if you use cookies or other headers.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39168898
I have had to do 'emergency repairs' on a couple of websites because the host upgraded PHP.  The move from PHP 4.4 to PHP 5.3 can break a lot of things.  It caused so much trouble that the host backed down to PHP 5.2 which was much more compatible with the old code.
0
 

Author Comment

by:BrighteyesDesign
ID: 39168918
I've been crying in a corner since I discovered this.

So much work to do it's incredible. And what about templated carts like Prestashop? I have a couple of sites using that and wouldn't have a clue how to alter that code.

Guessing there's going to be a lot of posts on this site along the lines of.."how do I change this MySQL code to MySQLi"!
0
 
LVL 44

Accepted Solution

by:
Chris Stanyon earned 668 total points
ID: 39168989
I wouldn't overly stress about this - these things don't usually happen over night - it often takes years between an announcement of deprecation and a flat out non-supported fatal error!! All of the big players such as Prestashop etc should be updating their core code to ensure it's suitable - if not, they won't keep their customer base for very long.

If you're overly concerned, talk to your host and ask what their timescale is for updating PHP.

Bear in mind that the mysql extenstion will be deprecated from PHP 5.5, and probably won't be removed until 5.6 or 5.7 - we're only on 5.4 at the moment so technically it's not even deprecated yet.

You should definitely be using mysqli or PDO for any new code that you write, but I certainly wouldn't start panicking over old sites just yet :)
0
 

Author Comment

by:BrighteyesDesign
ID: 39169007
Thanks for that Chris, i'll get stuck into mysqli and should know my way around it by the time it stops for good!
0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 668 total points
ID: 39169030
I agree with Chris.  A more immediate problem on upgraded versions of PHP can be $HTTP_COOKIE_VARS, $HTTP_POST_VARS and $HTTP_GET_VARS which caused almost all the problems in the site I had to rescue.  The 'mysql' code worked fine.
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 664 total points
ID: 39169933
I agree with Chris, too.  It's not a bus hurtling toward you, it's more of a problem that can be handled in your spare time.  But it will have to be handled eventually.  In my experience the easiest MySQL change has been to move from MySQL to MySQLi in the object-oriented format.  The procedural format will require you to change all of your query statements because the argument order is reversed (what was PHP thinking when they did that??)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question