Solved

How can I connect to my Database via GoDaddy?

Posted on 2010-08-16
27
669 Views
Last Modified: 2013-12-13
Hi,
Well I am using Dreamweaver and although there are a lot of discussions regarding this topic I have yet to figure out what my issue is.  I cannot connect to my database via the Dreamweaver wizard.  Can I just bypass the wizard and hand code my own connection file?  I am using PHP/MySQL.  I can connect to the FTP  I have spent 2 days on this.  I get code error 404.  There is no testing server running.

Please help!
0
Comment
Question by:napsternova
  • 9
  • 8
  • 7
  • +1
27 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 33448756
Hi napsternova,

You can create your own connection file but DW will probably not recognize it and let you use it in conjunction with its wizards.  If you are a hand-coder and not using the wizards, then go for it.

Otherwise, you need to work with GoDaddy support to fix the issue.  It is usually caused by some incorrect setting (either you have the name of the server wrong or the wrong login credentials OR the database user is restricted from accessing the database in some way -- domain name or IP address are common).   This is a fairly endemic problem with GoDaddy but I've seen it fall both ways.
0
 
LVL 28

Expert Comment

by:chilternPC
ID: 33448880
sometimes where the connection says "local server" i.e. 127.0.0.1  or what ever it is
find out the actual IP address of where the database is  and use that - or if you are using the actual IP address try the local 127.0.0.1 one.....
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 33448903
Godaddy MySQL connections are strictly Local unless you set it up otherwise.  I have one setup for remote connections and it works from this computer.  It uses the standard connection setup for PHP/MySQL.
0
 

Author Comment

by:napsternova
ID: 33449337
Dave,
So you are able to use Dreamweaver?  I have never had this type of issue before.  I created a new database and I have it set up to allow remote access.  I like the simplicity of drag/drop dynamic fields and text but without a connection I cannot create a recordset.
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 33449527
I don't use Dreamweaver but I occasionally help fix it's code.  Below is my generic PHP/MySQL connection page that I just used to connect to my Godaddy MySQL database.  You can run this from a web server but I don't know if it will work under Dreamweaver since Dreamweaver isn't a real browser or web server.
<?php 
// DB configuration
//$dbhost = "localhost";    // Your database server
$dbhost = "yourserver";    // Your database server
$dbuser = "yourusername";      // Your db username
$dbpass = "yourpassword";      // Your db password
$dbname = "yourdbname";      // Your database name
$dbtable = "yourtable";  // the table we're using

//mysql_connect('localhost', 'mysql_user', 'mysql_password');
$dbh = mysql_pconnect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Generic dbCheck</title>
<meta name="GENERATOR" content="HTMLKit">
<meta name="author" content="Dave Baldwin" />
</head>
<body>
<?php 
echo "$dbhost <br>";
?>
<table border="1" cellpadding="1" cellspacing="1" width="100%">
<caption><font style="font-weight: bold; font-size: 18pt; line-height: 24pt;">Generic dbCheck</font></caption>
<tbody>
<tr bgcolor="#ffffff">
<?php 
// Formulate Query
// For more examples, see mysql_real_escape_string()
$result = mysql_query("SELECT * FROM $dbtable LIMIT 10");
if (!$result) {
   echo 'Could not run query: ' . mysql_error();
   exit;
}

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo '<tr class="locmus">';
echo '<td>'.$row[0].'</td>';
echo '<td>'.$row[1].'</td>';
echo '<td>'.$row[2].'</td>';
//echo '<td>'.$row[3].'</td>';
//echo '<td>'.$row[4].'</td>';
//echo '<td>'.$row[5].'</td>';
//echo '<td>'.$row[6].'</td>';
echo '</td></tr>';
}
?>
</tbody> 
</table>

</body>
</html>

Open in new window

0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 33449566
The above will "work" in Dreamweaver in the sense that it's perfectly valid PHP and will allow you to hand-code stuff.  But if you want to work with DW wizards, you have to let DW write its own code.

Dave has it right with http:#a33448903 but you may need to contact GoDaddy support to make sure that you are indeed set up for remote access and that the user is not limited to a specific domain or ip range.

0
 

Author Comment

by:napsternova
ID: 33454119
So since I cannot use Dreamweaver for its intended purpose, is it easy enough to build the site locally and then upload the whole thin and change the database connection parameters?  If this were my site I would find a new host, I've spent 2 days trying to get Dreamweaver to work.  Any ideas for building a contanct management system?
0
 
LVL 28

Expert Comment

by:chilternPC
ID: 33454372
buy one off the shelf or get an open source one for free...
they all come working out of the box

list of open source here...
http://php.opensourcecms.com/scripts/show.php?pagenumber=2&catid=all
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 33456325
>> So since I cannot use Dreamweaver for its intended purpose

Sure you can.  All you need to do here is talk to GoDaddy support and get them to help you with the connection parameters.  Better yet, host elsewhere...there's plenty of low-cost, high-feature hosting to choose from out there.
0
 

Author Comment

by:napsternova
ID: 33457357
jason1178,
yeah I talked to them 3 times.  They all seemed interested in helping but when it was all said and done I am here looking for answers.  I keep getting the testing server not active or installed, I forget which.

I would switch but it isn't my site.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 33457382
Can you connect to the DB through a browser (i.e. use phpMyAdmin)?
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 33457650
This is a bit of a puzzle to me because I used the code I posted above to connect to my MySQL database on my Godaddy Windows IIS7 hosting from this computer running Windows 2000 with IIS5.0 and PHP 5.2.5.  I also use similar code for a customer running on Godaddy Linux hosting.  So the connection details are the same as any other MySQL setup if you have set it up for remote access which is just a checkbox on the setup request.  You have to get the 'connection details' from the database page in the Hosting Control panel.  Other than that, Dreamweaver really shouldn't have a problem with it.  It's plain vanilla stuff.

Which hosting, Linux or Windows, are you using?  And did you try the test page I posted above?
0
 
LVL 28

Expert Comment

by:chilternPC
ID: 33460032
what version of dreamweaver do you have?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:napsternova
ID: 33460935
jason - yes I can access phpmyadmin
dave - hosting is Linux, what should I save the file as and then where should it be saved.  This site has a bunch of aliases so I am uploading my site to an alias folder.
chilternPC - Dreamweaver CS4
Thanks all  
0
 

Author Comment

by:napsternova
ID: 33461019
Dave - OK that file works, I am starting to get really confused.  So do I need to hand code my forms, logins and reports?  
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 33461032
That's a possibility but since I don't have or use Dreamweaver, I suggest you work it out with the others.  Maybe they can tell you how to get Dreamweaver to cooperate since we now know that the connection works.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 33461049
Try this...

From Dreamweaver, open the FTP log (Windows | Results | FTP log)

Once the FTP log is open, do Site | Advanced | Remove Connection Scripts

You should see some activity in the FTP log that shows a number of files being checked and then removed.

After that's complete, edit your site definition and make sure the testing server settings and remote server settings are correct.  For simplicity, set both of them to be the same (i.e. point the testing server at GoDaddy) and make sure the Host Directory the remote and testing servers are the public site root.

Then switch to the Databases panel and redefine the Connection.  You should see activity in the FTP log as new files are uploaded to GoDaddy.  Open a new page and attempt to create a recordset...
0
 

Author Comment

by:napsternova
ID: 33461079
Dave - If I may ask, what do you use?  Seems like Dreamweaver writes extra code that Godaddy doesn't like.  That's fine if the code is cleaner and faster, I can adapt.  Too bad this little job is going into week 2.
0
 

Author Comment

by:napsternova
ID: 33461085
jason - will do, thanks
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 33461120
I hand code everything in HTML-Kit.  You saw the code I actually use.  Many, many times.  Well, what follows the connection gets a lot more complicated but that's the way it starts.  I wonder about what Dreamweaver is writing because the code I posted is like the basic code form the PHP demo page.  There are two other ways of doing it.  Maybe Dreamweaver is using one of them.  With your login info removed, can you post the code it's generating for you?
0
 
LVL 70

Assisted Solution

by:Jason C. Levine
Jason C. Levine earned 250 total points
ID: 33461150
Dreamweaver does a couple of things that it really shouldn't.  First off, a connection in DW is simple:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_connNAME = "mysql.domain.com";
$database_connNAME = "database";
$username_connNAME = "username";
$password_connNAME = "password";
$connNAME = mysql_pconnect($hostname_connNAME, $username_connNAME, $password_connNAME) or die(mysql_error());
?>

That's the include file called from every page.  Nothing unusual there.  But in order to connect to the DB from the DW program and get the file and table information, DW also creates a folder on the web site called _mmServerScripts and puts two files in there (MMHTTPDB.php and mysql.php).  Those two files are critical for allowing DW to connect and display database information.  They are not used in the live application, so if you were to use the above information as the basis for your database calls, it would work just like DaveBaldwin's code works.

The issue here is how DW itself connects to the db, not so much the code it generates.   The most common issues with DW database connections are incorrect Site path definitions.  If the above folder is not present in the public root of the site, DW cannot use its internal stuff.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 33461315
Godaddy MySQL servers for external access are not on the web domain but on a separate domain they have for the servers.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 33461350
Doesn't matter as far as DW is concerned.  If the mysql user has permission to access the remote server from any IP address and the site definition is correct in DW, it should work.
0
 

Author Comment

by:napsternova
ID: 33462067
Wow, I actually got DW to connect and create a Recordset.  I will post my findings
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 33466862
Great!
0
 

Author Closing Comment

by:napsternova
ID: 33501355
Thank you so much for all your help.  I am not 100% sure why "all of a sudden" it connected but it did.  I will inspect it once I am done with the job.  I split the points because both of you contributed pretty equally.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 33502865
Thanks.  You probably got all the pieces right.  Glad to help.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now