Copy link to clipboard
Copied
I am trying to set up a form to to send info to a database. I have set up my database called contact_form, with 2 fields name and email. I use awardspace.co.uk (free) but i cant seem get it to work. can someone look at both my form and PHP codes and see where i am going wrong. thanks
FORM CODE
PHP CODE (mysql_connect("(database_name).mysql.aplus.net - i am not sure if this is correct if i want to connect to my awardspace mysql???)
Copy link to clipboard
Copied
This thread has been moved to the Dreamweaver Application Development forum, which deals with PHP and other server-side issues.
What do you mean when you say it doesn't "seem to work"? Do you get any error messages? Are you testing this on your local computer or on your website? Most hosting companies do not permit remote access to the database. Also, the name of the database server depends on what the hosting company has told you to use. In most cases, it's simply "localhost".
Copy link to clipboard
Copied
thanks for your reply
error message:
Warning: mysql_connect(): Unknown MySQL server host '(database_name).mysql.aplus.net' (1) in /home/www/videoadvantage.awardspace.co.uk/Pages/formindb.php on line 2
Could not connect: Unknown MySQL server host '(database_name)fdb2.awardspace.com' (1)
i have uploaded both php and html form to my pages folder via ftp. im using mysql that awardspace provides. i made a table called patient.
details of my database:
| # | DB Host | DB Name | DB User | DB Version | Space Quota | Used Space | Options |
| 1 | fdb2.awardspace.com | patient | patient_contact | MySQL 5.1 | 10 MB |
Copy link to clipboard
Copied
$con = mysql_connect("fdb2.awardspace.com","patient_contact","password")
or die(mysql_error());
mysql_select_db('patient', $con);
// rest of script
Copy link to clipboard
Copied
NEW PHP SCRIPT:
<?php
$con = mysql_connect("fdb2.awardspace.com","patient_contact","password")
or die(mysql_error(cannot connect));
mysql_select_db('patient', $con); //Replace with your MySQL DB Name
$name=mysql_real_escape_string($_POST['name']); //This value has to be the same as in the HTML form file
$email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file
$sql="INSERT INTO contact_form (name,email) VALUES ('$name','$email')"; /*form_data is the name of the MySQL table where the form data will be saved.
name and email are the respective table fields*/
if (!mysql_query($sql,$con)) {
die('Error: ' . mysql_error());
}
echo "The form data was successfully added to your database.";
mysql_close($con);
?>
NEW ERROR:
Parse error: syntax error, unexpected T_STRING in /home/www/videoadvantage.awardspace.co.uk/Pages/formindb.php on line 3
thanks
Copy link to clipboard
Copied
ok i have fixed it forgot the ' '.
now i have
ERROR: no database selected
in my browser, but it is defiently the correct name of db
Copy link to clipboard
Copied
Try changing this:
mysql_select_db('patient', $con);to this:
mysql_select_db('patient', $con) or die(mysql_error());That should tell you what happens when you try to select the database.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more