I have been working on a website recently that needs to contain databases with things like emails (used as user name), passwords, and other information on the user. The problem I have been having is accessing the database using PHP. When I view this file in my browser, it only shows "connecting..." and doesn't continue with anything. I called the tech support, and that is the information they said to use, but its not working. I figured even if the information wasn't correct, it should go to the IF statement that displays an error, but that doesn't happen. Here is code that I have attempted to use to connect to the database. The domain is registered with Register.com if that helps. As you can tell, I am very new to PHP and SQL, so any help would be greatly appreciated.
try with a simple script like this to see if it connects ok ->
// Connect to database.
@mysql_connect("localhost", "loginname", "password") or die('<font face="helvetica">At this time we are unable to connect to the Database.<br><br>The most likely cause is a problem with the server hosting the database.<br><br>Please try again later as these problems tend to be transient.<br><br>We apologise for the inconvenience.</font>');
@mysql_select_db("databasename") or die("Unable to select db");
If this works with your info, maybe there's a typo somewhere in the other script?
In this script too, "localhost" may need to be changed to the address of your ISP's server.
December 13th, 2007, 10:42 PM
I attempted to use localhost and the host i previously posted, both of which returned the answer: At this time we are unable to connect to the Database....
December 13th, 2007, 10:59 PM
Have you verified username, host information, password etc etc?
your PHP connect to the MySQL database isn't working.
Also you have an error in your connection string.
$cxn = mysqli_connect
$cxn = mysql_connect
December 14th, 2007, 07:06 AM
That mysqli statement is correct if the MySQL is version 4.1 or above.