Web Hosting Talk







View Full Version : MySQL/PHP and Dreamweaver


crystalweb
08-13-2004, 06:09 AM
I have started to create a new site that will read info from a MySQL database. Within Dreamweaver I am trying to connect to my database.

Using the "Application Panel" and the "databases tab", I try to create a new connection to my database. I fill in the feilds using localhost as my "MySQL Server"

When I click on the "Select" database button I get th following error;

"An unidentified error has occurred"

I have PHP/MySQL and Apache setup and working on my local machine. I have uncommented the "include_path" within php.ini
I have also setup my Site details within Dreamweaver ok.

Is there something im missing?

Please help.

overulehost
08-13-2004, 09:57 AM
This sound complicated,
I thought dreamweaver is only edit html files....
well i am not sure about that

KamiDev
08-13-2004, 10:53 AM
Yea, Dreamweaver can modify .php too.

Don't, however, use Dreamweaver's method of "coding" (if you would even call it that).


<?
$sql_host = "localhost";
$sql_uname = "username";
$sql_pass = "password";
$database = "database";

$connect = mysql_connect($sql_host, $sql_uname, $sql_pass);

if (!$connect) {
die('Error in connection: ' . mysql_error());
}

$db = mysql_select_db($database, $connect);

// You can do additional queries here.

?>


There's a quick little MySQL connection script (crappy, but should work). Use that, or the thousands of other scripts on the internet.

thartdyke
08-13-2004, 12:08 PM
I tried using Dreamweaver's PHP 'features', and you're better off just using it as a text editor (which it's pretty good at). I found the abstraction layer that DW introduces is more obfuscationg than helpful. You still need to know what's happening underneath, but Dreamweaver hides it all from you.

I find the best approach to combining the two is to write all the PHP by hand, but make sure you're outputting raw HTML most of the time (rather than using 'echo') so you can see the layout onscreen.

Toby