|
-
Jul 27th, 2012, 09:36 AM
#1
Thread Starter
Addicted Member
PHP to mySQL Connect to DB
Alright, I am at a very beginner stage of learning PHP and have attempted to find the solution to this problem on my own; but with no luck. So any advice is appreciated.
I have a website that is hosted on Bluehost and have setup a database with tables on the same host, same account. I can login to this database through phpMyAdmin, and did so to setup the tables. So I know my username/password is correct.
The script on my web page is this:
PHP Code:
<?php include 'header.php';
$username ="anaddmin_rmd";
$password = "DidThis65?";
$host = "localhost";
$conn = new mysqli($host, $username, $password);
if (!$conn)
{
die('Could Not Connect to Server: ' . mysql_error());
}
mysql_select_db ("anaddmin_stpsormd") or die ("Could Not Connect to Database:" . mysql_error());
$sql="INSERT INTO options (options_make, options_model, options_ecp, options_bootapp, options_burnapp, options_mcu, options_ch721)
VALUES ('$_POST[make]','$_POST[model]','$_POST[ecp]','$_POST[bootapp]','$_POST[burnapp]','$_POST[mcu]','$_POST[ch721]',)";
if (!mysql_query($sql,$conn))
{
die ('Error: ' . mysql_error());
}
echo "Record added";
?>
Username and Password were altered for security but the format is exactly the same as above, in case it's part of the problem.
So anyway, I have an HTML form on the page with a few text-boxes and when I fill them out and click 'submit', I get this error:
Could Not Connect to Database:Access denied for user 'root'@'localhost' (using password: NO)
On a seperate occassion I have verified that the server connects just fine. I only receive an error when attempting to select the database (name has not been altered).
Any ideas? I'd really appreciate it...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|