I am getting the below error when attempting to run a php script on my server which accesses a mysql table I have created in an existing database. I can connect to the database table via the MySQL workbench, but not via a php script I have written. This database was originally created for use with Magento Cart, which I have installed and which works correctly (can access it's database tables). I simply cannot access the database with a separate script which I have separately created. The script runs and echoes the statement to the screen, but then fails on the connection.
Could not connect: Access denied for user 'cars2'@'VWEB2' (using password: YES)PHP Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'cars2'@'VWEB2' (using password: YES) in C:\HostingSpace s\car.accessori es\caraccessori es.com\wwwroot\ magento\uploadQ uestion.php on line 4
------------------php script--------------
Could not connect: Access denied for user 'cars2'@'VWEB2' (using password: YES)PHP Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'cars2'@'VWEB2' (using password: YES) in C:\HostingSpace s\car.accessori es\caraccessori es.com\wwwroot\ magento\uploadQ uestion.php on line 4
------------------php script--------------
Code:
<?php
echo "test<br>";
$con = mysql_connect("server", "username", "password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("cars2", $con);
$sql="INSERT INTO survey_questions (survey_question_text, survey_question_visible, survey_question_options, survey_question_style) VALUES ('$_POST[survey_question_text]',,'$_POST[survey_question_status]','$_POST[survey_question_options]', '$_POST[survey_question_style]] )";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con);
?>
Comment