Now I have another error message which is:
1054: Unknown column 'fff' in 'field list'
The problem is that i am trying to create a php file to write on a mysql database.
Codes are like this:
FORM:
<?
echo("
<form method=\"post\" action=\"formhandle4.php\">
Name: <input type=\"text\" name=\"mytextbox\" /><br/>
<p><input type=\"submit\" name=\"mybutton\" value=\"Submit\" /> <input type=\"reset\" value=\"Reset Form\" /> </p>
</form>
");
?>
formhandle4.php:
<?php
if (isset($HTTP_POST_VARS['mybutton'])) {
global $HTTP_POST_VARS;
echo "You clicked the button\n";
echo "You typed ". $HTTP_POST_VARS['mytextbox'] . " in the textbox.<br>\n";
$Host = "...";
$DBName = "...";
$TableName = "...";
$Link = mysql_connect ($Host, '...', '...');
if ($Link==false) {
echo mysql_errno().": ".mysql_error()."<BR>\n";
}
mysql_select_db ($DBName, $Link);
$Query = "INSERT INTO $TableName VALUES ($HTTP_POST_VARS[mytextbox])";
if (mysql_query ($Query, $Link)) {
print ("The query was successfully executed!<BR>\n");
}
else {
print ("The query could not be executed!<BR>\n");
echo mysql_errno().": ".mysql_error()."<BR>\n";
}
}
else {
echo "you must have come here from somewhere else.\n";
}
?>
When i submit the form by typing fff i get this message:
You clicked the button You typed fff in the textbox.
The query could not be executed!
1054: Unknown column 'fff' in 'field list'
When i change the query like this:
$Query = "INSERT INTO $TableName VALUES ('some string')";
some string will be added to the database.
On the other hand I know that the variable $HTTP_POST_VARS[mytextbox] is true because i got the message
You clicked the button You typed fff in the textbox.
What should i do?
Cheers.
MEG