Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Jul 4, 2009, 15:19   #1
gxdante
SitePoint Member
 
Join Date: Jul 2009
Posts: 2
Unhappy PHP MySql Site Dreaweaver Error

Here goes

I'm building a php site that is suppose to connect to a mySql database in dreaweaver cs4.

I use Xampp to install Apache, PHP, MySql, phpMyadmin they work great I've tested the server and its fine.

I setup the site properly putting the folder in htdocs, the Url prefix is also as it should be. I've double checked these settings and visited a lot of tutorials.

When i preview the index page it works on the localhost.

The problem: is when i try and add a database to the page, i've created the database in phpMyadmin. In dreamwever CS4 wen i click the (+) sign in database and Click on Mysql Connection.

I filled the form as follow

Connection name: test
MySql Server: localhost
User name: (myusername)
Password: (mypassword)
Database: (database name)

I get this error message when i test:
Server timeout, reasons
1.Please make sure web server is up and running.
2.Please verify that the ODBC DNS exists on the testing server.

Any help would be greatly appreciated..
Attached Images
File Type: jpg error.jpg (57.9 KB, 13 views)
gxdante is offline   Reply With Quote
Old Jul 5, 2009, 07:57   #2
molona
Community Advisor
 
molona's Avatar
 
Join Date: Feb 2005
Location: from Madrid to Heaven
Posts: 3,049
Since you're connecting to a MySQL database, you don't have a DSN connection. You're timeout comes because something is not properly written.

Make sure that your spelling is exact to the names you used (for database, username, passwords... MySQL does know the difference between a capital letter and a lower case one )

Make sure that MySQL service is active and working.

Also, if you want to know what's happening remove the "die" bit (I think you don't have it but...)

Example:

Dreamweaver would have written something like this:
PHP Code:
mysql_connect("localhost","user","pass") or die("message to be displayed if the connection could not be done")
mysql_select_db("database_name") or die("message if the connection could not be opened");

The "die" bits stop PHP from giving you a default error message and that's great when the site is shown to the public (they will not see the errors with messages they can't understand) but it is not so good for you, because you don't know what happens.
molona is offline   Reply With Quote
Old Jul 5, 2009, 08:59   #3
primozc
SitePoint Enthusiast
 
primozc's Avatar
 
Join Date: Nov 2008
Location: Slovenia, EU
Posts: 51
I had several times very similar problems with Dreamweaver and connecting to the database. The only solution I found working was reinstall. And that's why I started to use aptana studio. At first it's hard to work without the WYSIWYG editor but when you get used to it's much better and easier.
primozc is offline   Reply With Quote
Old Jul 5, 2009, 09:05   #4
Jake Arkinstall
Formerly 'arkinstall'
 
Jake Arkinstall's Avatar
 
Join Date: May 2006
Location: Powys, Mid Wales
Posts: 6,173
@Molona: Not quite. The die() bit is required because otherwise the program will continue and throw a gazillion errors at the programmer, which may or may not be because of one single error.

However, by using die() (or exit - they do the same thing) in conjunction with the MySQL_Error() function, you can see what went wrong and stop the program:

PHP Code:

MySQL_Connect('localhost', 'user', 'pass') or die('Cannot Connect: ' . MySQL_Error()); 
MySQL_Select_DB('database_name') or die('Cannot Select Database: ' . MySQL_Error());
Off Topic:

Is this when trying to run the page, or when testing the connection? I was under the impression that this was a dreamweaver testing part before it even hits PHP, hence my request for it to be moved
Jake Arkinstall is online now   Reply With Quote
Old Jul 5, 2009, 09:09   #5
Jake Arkinstall
Formerly 'arkinstall'
 
Jake Arkinstall's Avatar
 
Join Date: May 2006
Location: Powys, Mid Wales
Posts: 6,173
Quote:
Originally Posted by primozc View Post
I had several times very similar problems with Dreamweaver and connecting to the database. The only solution I found working was reinstall. And that's why I started to use aptana studio. At first it's hard to work without the WYSIWYG editor but when you get used to it's much better and easier.
Every time someone uses a WYSIWYG editor, a kitten dies. Well, not quite, but it's a bad thing. Wysiwyg editors produce terrible code (tables, terrible semantics and css, terrible PHP code output too), and PHP/JS/HTML/CSS are very human-friendly markup languages that should be handwritten anyway.

You will find your code quality improves 10^100 times by handcoding.
Jake Arkinstall is online now   Reply With Quote
Old Jul 5, 2009, 09:15   #6
primozc
SitePoint Enthusiast
 
primozc's Avatar
 
Join Date: Nov 2008
Location: Slovenia, EU
Posts: 51
Quote:
Originally Posted by arkinstall View Post
Every time someone uses a WYSIWYG editor, a kitten dies. Well, not quite, but it's a bad thing. Wysiwyg editors produce terrible code (tables, terrible semantics and css, terrible PHP code output too), and PHP/JS/HTML/CSS are very human-friendly markup languages that should be handwritten anyway.

You will find your code quality improves 10^100 times by handcoding.
That's exactly what I wanted to say. If you thing that Dreamweaver gives you a good workspace - go and try to code something directly And you will see what you were totally wrong about it ...
primozc is offline   Reply With Quote
Old Jul 5, 2009, 10:23   #7
molona
Community Advisor
 
molona's Avatar
 
Join Date: Feb 2005
Location: from Madrid to Heaven
Posts: 3,049
Quote:
Originally Posted by arkinstall View Post
@Molona: Not quite. The die() bit is required because otherwise the program will continue and throw a gazillion errors at the programmer, which may or may not be because of one single error.
Let me repeat. You want to use die() when the site is up and running, but not when you're trying to find the error because... if you don't see the errors, how do you expect to find them?

I don't think that it will bring to might light to this particular case though. It seems that it doesn't connect to the database at all and that makes me think of misspelling, MySQL service not running or bad installation.
molona is offline   Reply With Quote
Old Jul 5, 2009, 10:51   #8
Jake Arkinstall
Formerly 'arkinstall'
 
Jake Arkinstall's Avatar
 
Join Date: May 2006
Location: Powys, Mid Wales
Posts: 6,173
Quote:
Originally Posted by molona View Post
Let me repeat. You want to use die() when the site is up and running, but not when you're trying to find the error because... if you don't see the errors, how do you expect to find them?
That's my point

You DO see the errors, because MySQL_Error gives you the errors. So, you use die('error: ' . MySQL_Error()); so that it outputs the database error and stops the script from running further, potentially causing problems.
Jake Arkinstall is online now   Reply With Quote
Old Jul 5, 2009, 11:14   #9
molona
Community Advisor
 
molona's Avatar
 
Join Date: Feb 2005
Location: from Madrid to Heaven
Posts: 3,049
I think that we have different systems to debug. Connection errors (especially at this early stage) do not throw a list of thousand errors. He could do that, of course. It is just another way.
molona is offline   Reply With Quote
Old Jul 5, 2009, 11:24   #10
Jake Arkinstall
Formerly 'arkinstall'
 
Jake Arkinstall's Avatar
 
Join Date: May 2006
Location: Powys, Mid Wales
Posts: 6,173
Quote:
Connection errors (especially at this early stage) do not throw a list of thousand errors.
It's not the error itself that's the issue. If the database connection fails to open, then all the queries you're going to be running will fail and show errors too - then the calls for results, loops, row counts. All of those will output errors, so one small error could cause much bigger problems.

If a database connection fails, chances are the site will be severely broken anyway. In which case, killing it before it causes damage is a good move. Usually you'd include error details before killing it (hence mysql_error()), and that could vary depending on the development stage you're in.
Jake Arkinstall is online now   Reply With Quote
Old Jul 5, 2009, 11:38   #11
crowden
derrrp
 
Join Date: Aug 2006
Location: earth
Posts: 887
Quote:
Originally Posted by primozc View Post
That's exactly what I wanted to say. If you thing that Dreamweaver gives you a good workspace - go and try to code something directly And you will see what you were totally wrong about it ...
I only use the code view in Dreamweaver and love it. Code hints, site-wide find-replace and its site/file management features all make my workflow faster.

As far as the WYSIWYG features go...they're all left alone and completely worthless, IMO.
crowden is offline   Reply With Quote
Old Jul 5, 2009, 11:52   #12
molona
Community Advisor
 
molona's Avatar
 
Join Date: Feb 2005
Location: from Madrid to Heaven
Posts: 3,049
Let's get back to topic, shall we? This is not about different ways of working, if die() should be there or not, or if DW is great or not as a development tool.

Let's wait and see if anyone else can provide better solutions or if gxdante manage to give us more information so we can narrow the problem
molona is offline   Reply With Quote
Old Jul 5, 2009, 12:05   #13
primozc
SitePoint Enthusiast
 
primozc's Avatar
 
Join Date: Nov 2008
Location: Slovenia, EU
Posts: 51
@molona: you're right, go back to the topic. But unfortunately Dw doesn't works fine with database connection and does not recognize it if you write it on your own. That's my point of view.
primozc is offline   Reply With Quote
Old Jul 8, 2009, 06:28   #14
gxdante
SitePoint Member
 
Join Date: Jul 2009
Posts: 2
Thanks all who have contributed but my problem remains.

1. The server is running
2. I double checked the connection data , user name etc... all correct

This is the automatic code written by dreamweaver for the connection..

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_test = "localhost";
$database_test = "test";
$username_test = "root";
$password_test = "*****";
$test = mysql_pconnect($hostname_test, $username_test, $password_test) or trigger_error(mysql_error(),E_USER_ERROR);
?>
gxdante is offline   Reply With Quote
Old Jul 8, 2009, 22:51   #15
eruna
SitePoint Addict
 
Join Date: Jan 2007
Posts: 392
Dreamweaver is good for css coding, but using the WYIWYG for php/mysql?? You are blowing my mind.
eruna is offline   Reply With Quote
Old Jul 11, 2009, 00:32   #16
crowden
derrrp
 
Join Date: Aug 2006
Location: earth
Posts: 887
Hi,

Have you set up the testing server settings for your site?

Go to Site->Manage Sites and edit the one your working on. If it's on Basic, switch to Advanced. Then go to the Testing Server option on the left.

I've attached an image. It's from DW8, but the interface should be similar.

For the URL Prefix, leave it to localhost unless you have virtual hosts set up.

Hope that helps, though I'm not 100% if that'll do it.
Attached Images
File Type: jpg dwTestingServerSettings.jpg (33.9 KB, 3 views)
crowden is offline   Reply With Quote
Reply

Bookmarks

Tags
php

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
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 On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 13:27.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved