Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

I can't get a database connection.

Community Beginner ,
Jun 01, 2013 Jun 01, 2013

Background: I've already built two sites with databases using DW CS6, PHPMySQL, and the same hosting company, so I know they allow remote connections. (I'm developing using the remote host because I've never found a tutorial for how to move it all from local XAMPP to my host - but hey, it's been working fine so far.)

I set up the database using CPanel Databases, added the user and password, no problem. Went into PHP MySQL and added a table, logged out and back in, the table is there as defined.

In DW, I double-checked the testing server, tested the connection, and it connected successfully.

Then I opened a page for editing and added a database connection (all as I had done on the previous two sites that work fine). I named the connection, entered the user, the password and tried to SELECT a database. No luck. HTTP Error 404. I manually added the database (the only one) and clicked test. Again no luck. HPPT Error 404.

I double checked the testing server, double checked the DB information, and nothing seems to work.

Any clue what I'm doing wrong? Thanks so much if you can help.

TOPICS
Server side applications
2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Jun 01, 2013 Jun 01, 2013

You might want to check with your host service.  You note you work through CPanel and so did I some time back.  Had a similar problem, everything worked locally but not on the live site. 

The MqSQL connection string(s) need to have the cPanel login ID prefixing the database name and the user name

(eg., I was working a tutorial (check_mag); DW developed the connection file containing:

$hostname_check_mag = "localhost";

$database_check_mag = "php_test";

$username_check_mag = "phptestuser"

$password_ch

...
Translate
Participant ,
Jun 01, 2013 Jun 01, 2013

You might want to check with your host service.  You note you work through CPanel and so did I some time back.  Had a similar problem, everything worked locally but not on the live site. 

The MqSQL connection string(s) need to have the cPanel login ID prefixing the database name and the user name

(eg., I was working a tutorial (check_mag); DW developed the connection file containing:

$hostname_check_mag = "localhost";

$database_check_mag = "php_test";

$username_check_mag = "phptestuser"

$password_check_mag = "abcdefghij";

$check_mag = mysql_pconnnect($hostname_check_mag, $database_check_name, $username_check_mag, $password_check_mag) or trigger_error(mysql_error(),E_USER_ERROR);

I was advised by Host support that $database_check_mag = "cpanelid_php_test" (eg: "zyxwvu_php_test") [where zyxwvu is my cpanel id AND the $username variable formatted the same way.

I'm not using that host any longer so don't know if they changed things since then.  Worth a try!

Tom

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 02, 2013 Jun 02, 2013

Hi Tom,

Thanks for this, but I've already been doing that.

Please note that I've already developed two other DB-driven sites in DW using this same host (HostGator), so I'm pretty sure it's not the host that's the problem.

I've double-checked both my testing server information and my Database Connection information not only against what I know it to be, but also against the two already-functional sites I have, just to see if there's some formatting issue I'm missing.

For the life of me I can't figure out what's wrong.

Two sites work just fine, this third one refuses to get a connection. Very frustrating.

David

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 02, 2013 Jun 02, 2013

Hi David,

Sorry my reply wasn't much help; it was something so similar to the problem I had a while back that I had to note it.

I was about to say it's the small things, quite possibly a missing or similar punctuation that might be the cause WHEN I NOTED in the example I included earlier the missing semi-colon at the end of $username line.  I though I had copied it exactly!  It's usually the small things!

Good luck,

Tom

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 02, 2013 Jun 02, 2013

>so I know they allow remote connections.

DW does not connect directly with your remote database. It uses helper files located in the _mmServerScripts folder. Make sure that folder exists in the root directory on your server.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 03, 2013 Jun 03, 2013

Thanks so much for this suggestion.

I was hopeful this might be the problem, so I logged in to one of my operational DB sites and found the folder, and copied it to my HD, just in case.

Then I logged in to both the sites I'm trying to establish a connection with. Fooey. That folder is already there, and the files in the folder are the same (name and bytecount) as in the sites for which the connections work.

Bummer. I was hoping this would fix it, but alas, no luck with this tweak.

Thanks anyway, I sure appreciate the help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 02, 2013 Aug 02, 2013

I see I posted this original problem back on Jun 1; now it's Aug 2, and I'm still frustrated by the same problem.

Hearty thanks to all of you who posted with suggestions. I've tried them all, with every permutation I can think of, and nothing seems to work. I have now tried to establish a DB connection on four OTHER sites, each with their own DB, and nothing seems to work.

I have double, triple, and quadruple checked the MySQL Server name, the User Name, and the Password. I keep getting the error message:

"The testing server specified for this site does not map to the http://(website URL here)/public_html/_mmServerScripts/MMHTTPDB.php URL. Verify that the URL Prefix maps to the root of the site."

The frustration level continues to mount.

If someone could PLEASE tell me how can I get a connection, I would be so very grateful.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 06, 2013 Aug 06, 2013
LATEST

UPDATE:

Okay, this is really getting weird. As a typcial computer nerd, I know there are many roads to success, so if one doesn't work, try another.

Trying a different solution, I opened a test.php page and wrote the following code:

<?php

echo "<p>Now testing database connection.</p>\n";

$db_server = "localhost";

$db_username = "mcsb831_mbradmin";

$db_password = "***(redacted)***";

$link = mysql_connect($db_server, $db_username, $db_password);

if (!$link) {

    echo "Could NOT connect.<br />\n";

}else{

    echo "Connected Successfully.<br />\n";

    mysql_close($link);

}

I loaded the page to the server and guess what? I got the message "Connected Successfully."

Hooray! Now I know the database server is running, and the database and user name and password are valid.

I went to the DW MbrConnect01.php file (the name of the CONNECTION file that Dreamweaver creates when I tried to make the connection through DW), and verified the database name, user name, and password were correct -- I copied and pasted them from the code above to make absolutely certain there were no transcription errors. Here's that file:

<?php

# FileName="Connection_php_mysql.htm"

# Type="MYSQL"

# HTTP="true"

$hostname_MbrConnec01 = "localhost";

$database_MbrConnec01 = "mcsb831_members";

$username_MbrConnec01 = "mcsb831_mbradmin";

$password_MbrConnec01 = "***(redacted)***";

$MbrConnec01 = mysql_pconnect($hostname_MbrConnec01, $username_MbrConnec01, $password_MbrConnec01) or trigger_error(mysql_error(),E_USER_ERROR);

?>

And guess what?

I GOT THE STINKING ERROR MESSAGE AGAIN!!

(See previous post for the full text of the message.

Yes, I checked the server using an FTP browser for the presence of the required files, and they are there.

Does anyone have a clue what's going on here? I would absolutely love to use DW's DB automation tools, but none of them will work if I can't get a DW connection to work.

I notice that my code uses mysql_connect while the DW-generated code uses mysql_pconnect (which is deprecated), could that be the culprit? How do I fix it if so?

PLEASE, can someone help?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines