Skip to main content
Known Participant
April 7, 2011
Answered

mySQL test server to real server

  • April 7, 2011
  • 3 replies
  • 710 views

Hi all,

I realise to most people in this forum this will be an easy and very amateur question, but im still fairly new to mySQL databases in Dreamweaver and their connections etc

Iv been working on an ecommerce site for several weeks and now it is ready to be uploaded and tested on its live internet server, I have a domain with a database set up, I have exported the SQL database into a word document, and imported it into the live server to get the database tables and forms generated in the new server etc.

I have updated my Dreamweaver site configuration so that now it points to the FTP where i upload the pages and files like i normally do with non-database websites and they have uploaded successfully. Where i am getting confused is about telling my connection to now look to the internet database, as opposed to the testing server on my computer

I would have guessed at editing the database connection in the 'Databases' panel and entering in the new information, but even when entering in the new data it cannot find anything, but i get the feeling i might be entering in the wrong information as it comes back with an error. Whereas the information before was

server name: localhost

username: root

password:

I feel im trying to enter in the wrong information, can someone clarify what details i need to enter to make my connection point to my live database rather than my local server

Many thanks

Andy

This topic has been closed for replies.
Correct answer

Don't rely on the database wizard in Dreamweaver to update your connection file. When you create a recordset in Dreamweaver for the first time Dreamweaver creates a Connection folder with a .php connection file inside it. This file is referenced at the beginning of dynamic pages in order to connect to the database. Locate the connection file that Dreamweaver has created for you and edit the settings there. Upload the saved file to the same location on your server and you should be good to go.

3 replies

WarDemonZAuthor
Known Participant
April 15, 2011

Thanks guys, i ended up editing the php file that is created when you run the wizard, cant believe it wouldnt just let me modify it anyway but as soon as i found the file it created from that set up, and modified the data myself it worked. Thanks for the help

Participant
April 14, 2011

Hi,

what I do is create a seperate php config file such as below

<?php
$user="user name";
$password="password";
$database="database name";
$dbAddress = 'database address';
mysql_connect($dbAddress,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");

?>

then just include this in the php files where you need to connect to your database.

This way if your developing locally withing Dreamweaver you can simply adjust the user name database address and password accordingly

Hopefully this will help

Harry,

The Spread Betting Beginner

WarDemonZAuthor
Known Participant
April 12, 2011

sorry to 'bump' the message as such but can anybody help with this

Known Participant
April 12, 2011

What I do is put my database log in above the web root, in the same location on both the testing and live servers.So if your website is in a folder called public_html or something like that, then the file with the log in can be in a folder at the save level as public_html, but not within it.This is very important for security.

The file, then is like this:

<?php function localhost(){
$connection = @mysql_connect('localhost', 'root', '');
if (!$connection) {
  exit('<p>Unable to connect to the ' .
      'database server at this time.</p>');
}
if (!@mysql_select_db('name_of_the_database')) {
  exit('<p>Unable to locate the database at this time.</p>');
}}?>

This file is called, for instance, db.php You want to have a version of the file for your testing server, as above, and a version for the live environment.

Then, on your pages, use code like the following to open the database connection:

<?php require_once '../file_name/.db.php'; ?>