|
Author |
Message |
scifo
Junior WebHelper
Joined: 27 Jul 2003
Posts: 4
|
Posted:
Wed Aug 06, 2003 1:55 pm (20 years, 8 months ago) |
|
I have a file which processes the data submitted by the form. I want to check whether the data submitted is identical to the data in mysql database so that if it is not the user corrects the form and submits it again. Here is the code which cannot check the data in submitted form:
Code: | <?php
global $HTTP_POST_VARS;
if (isset($HTTP_POST_VARS['mybutton'])) {
$Host = "***";
$DBName = "***";
$TableName = "patientsform";
$Link = mysql_connect ($Host, '***', '***');
if ($Link==false) {
echo mysql_errno().": ".mysql_error()."<BR>\n";
}
mysql_select_db ($DBName, $Link);
$Query1 = "SELECT Forename FROM patients WHERE Forename = {$HTTP_POST_VARS['forename']} AND Surname = {$HTTP_POST_VARS['surname']}";
//The query to check the data submitted
$Query = "INSERT INTO $TableName VALUES ('0', '{$HTTP_POST_VARS['forename']}')";
//The query to put the submitted data into the table
if (mysql_query ($Query1, $Link)) {
print "The query1 was successfully executed!<BR>\n";
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 {
print "The query1 could not be executed!<BR>\n";
echo mysql_errno().": ".mysql_error()."<BR>\n";
}
mysql_close($Link);
} //end of isset function
else {
echo "you must have come here from somewhere else.\n";
} |
MEG |
|
|
|
|
Darren
Team Member
Joined: 05 Feb 2002
Posts: 549
Location: London
|
Posted:
Wed Aug 06, 2003 3:18 pm (20 years, 8 months ago) |
|
Where abouts is the script failing?
any error messages? |
|
|
|
|
scifo
Junior WebHelper
Joined: 27 Jul 2003
Posts: 4
|
Posted:
Wed Aug 06, 2003 3:25 pm (20 years, 8 months ago) |
|
When i submit the form by writing 'Martin' in the forename area i get this error message
The query1 could not be executed!
1054: Unknown colomn 'Martin' in 'where clause'
Nevertheless, I know that there are 2 rows with the value of Martin in forename field.
???? |
|
|
|
|
Darren
Team Member
Joined: 05 Feb 2002
Posts: 549
Location: London
|
Posted:
Wed Aug 06, 2003 4:27 pm (20 years, 8 months ago) |
|
try putting the forename and surname variables in single quotes |
|
|
|
|
|
|
You cannot post new topics in this forum. You cannot reply to topics in this forum. You cannot edit your posts in this forum. You cannot delete your posts in this forum. You cannot vote in polls in this forum.
|
Page generation time: 0.116132 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme
| |