raydona Posted March 21, 2009 Share Posted March 21, 2009 Hi, I’ve written the following code. First is the HTML code which creates an online form with three text fields to be filled in by the user: Name, Occupation and Email Address. <html> <body> <FORM ACTION="some.php" METHOD="POST" NAME="some.html"> <TABLE> <TR> <TD><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Your Name:</font></TD> <TD> <input type=text name="name"></TD> </TR> <TR> <TD><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Your Occupation:</font></TD> <TD> <input type=text name="occupation"></TD> </TR> <TR> <TD><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Email Address:</font></TD> <TD><input type=text name="email"></TD> </TR> <TR> <TD><input type="submit" value="Submit" name="Submit"></TD> <TD><input type="reset" value="Reset" name="Reset"></TD> </TR> </TABLE> </FORM> </body> </html> Here is the PHP scipt which will take the data input from HTML file and send it to MySQL database. <html> <body> <?php $con = mysql_connect("some.net","Username","Password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DatabaseName", $con); $name=mysql_real_escape_string($_POST['name']); $occupation=mysql_real_escape_string($_POST['occupation']); $email=mysql_real_escape_string($_POST['email']); $sql="INSERT INTO table (name, occupation, email) VALUES ('$name', ‘$occupation’,'$email')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Form data successfully added."; mysql_close($con); ?> </body> </html> I get the following error: Error: Unknown column 'name' in 'field list' I do not know what is generating the error, especially as database contains table with respective fields name, occupation and email where the form data will be saved. I wonder if anyone can throw some light on the error. I would be very grateful. Link to comment https://forums.phpfreaks.com/topic/150464-cannot-send-text-input-to-mysqldatabase/ Share on other sites More sharing options...
bluejay002 Posted March 21, 2009 Share Posted March 21, 2009 From how I see it... its more like an SQL error. Check again if that certain column really exist in that table and check if the character casing also match. Link to comment https://forums.phpfreaks.com/topic/150464-cannot-send-text-input-to-mysqldatabase/#findComment-790286 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.