close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

random MySQL database connection fail...

Thread began 4/01/2014 10:44 am by Nathon Jones Web Design | Last modified 4/02/2014 8:02 am by Jason Byrnes | 1610 views | 5 replies |

Nathon Jones Web Design

random MySQL database connection fail...

Our connection to database has completely failed and our host support are pointing at our connection script which was working fine this morning and we haven't made any changes!

"Access denied for user 'OURUSERNAME'@'OURIPADDRESS' (using password: YES)"

We created a new user, updated our connection script and then received the following error:
"No database selected"

This is our connection script:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_njMySQL = "OURIPADDRESS";
$database_njMySQL = "OURDATABASENAME";
$username_njMySQL = "OURUSERNAME";
$password_njMySQL = "OURPASSWORD";
$njMySQL = mysql_pconnect($hostname_njMySQL, $username_njMySQL, $password_njMySQL) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_set_charset('utf8',$njMySQL);
?>

Has anyone come across this before? We have everything hosted on a VPS with cPanel access.
Appreciate it, thank you.
NJ

Sign in to reply to this post

Jason ByrnesWebAssist

normally the mySQL host should not use an IP address.

you should be able to access the database using phpMyAdmin.

in the top left corner, it will show the server address with the database name, use that server address for the host in the connection file.


if you are sure you have the correct information in the connection, you will need to work with the host to determine why it is being rejected by the server.

Sign in to reply to this post

Nathon Jones Web Design

We've checked with the host they responded...

"With regards to the host for the database, your server is the host so this is either localhost, 233382.vps-10.com or the IP address.

Checking this for you, the user has access to the database from the command line and creating a simple test script:
http://www.ledwarehouseuk.com/test.php

Works!"

This is the connection script they've used on test.php

<?php
// Create connection
$con=mysqli_connect("localhost","SAMEUSERNAMEASABOVE","SAMEPASSWORDASABOVE","SAMEDATABASEASABOVE");

// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else
{
echo "Connected";
}
?>

The difference appears to be in using "localhost" instead of the IP address, but when I try that in Dreamweaver the Define section tests successfully but when I try to open a recordset I get the same error. The website too displays the same error.

<sigh> I could understand if we'd changed something, but we didn't. This was all working fine, which you can confirm too because you've been assisting us with the site.

Why would this just stop?

I would appreciate your advice as I have no technical knowledge of MySQL at all.
I'm also, obviously, still chasing the host but their test connection works so they're pretty much saying that everything is fine.

Is this a Dreamweaver problem then?

Sign in to reply to this post

Jason ByrnesWebAssist

in the connection file try changing this line:

$njMySQL = mysql_pconnect($hostname_njMySQL, $username_njMySQL, $password_njMySQL) or trigger_error(mysql_error(),E_USER_ERROR);

to use mysql_connect instead of mysql_pconnect:
$njMySQL = mysql_connect($hostname_njMySQL, $username_njMySQL, $password_njMySQL) or trigger_error(mysql_error(),E_USER_ERROR);

Sign in to reply to this post

Nathon Jones Web Design

No change.

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_connLED = "localhost";
$database_connLED = "OURDBNAME";
$username_connLED = "OURUSERNAME";
$password_connLED = "OURPASWORD";
$connLED = mysql_connect($hostname_connLED, $username_connLED, $password_connLED) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_set_charset('utf8',$connLED);
?>

Our host is saying that our script is at fault, yet the script is built by Dreamweaver CC and, in the Define settings, connects successfully.
Utter nightmare this. I have lost 2 production days at a crucial time to this issue.

Hoping that you can help. Really appreciate it. Thank you.
NJ

Sign in to reply to this post

Jason ByrnesWebAssist

changing from mysql_pconnect to mysql_connect can sometimes take a little time to take effect, the active connections need to time out first.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...