我想知道是否有人可以帮助我解决这个烦人的问题。尝试将一些数据插入到表中。与此同时,我想省略一些领域,而不是在那里插入某些东西。出于某种原因,我得到Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
错误。有什么我在下面做错了吗?插入MySQL表错误
您的帮助将不胜感激。
<?php
function sqlEscape($string){
return "'".mysql_real_escape_string($string)."'";
}
if( $_GET['location'] == ''
|| $_GET['name'] == ''
|| $_GET['school'] == ''
|| $_GET['reason'] == ''
|| $_GET['address'] == ''
|| $_GET['postcode'] == ''
|| $_GET['email'] == ''
|| $_GET['telephone'] == '') {
exit('You missed a value');
}
include('theConfig.php');
$con = mysql_connect($host, $username, $password) or die(mysql_error()) ;
if (!$con){
die('Could not connect: ' . mysql_error());
} mysql_select_db($db, $con); //$description = mysql_real_escape_string($_GET[description]);
$sql = sprintf('INSERT INTO applications (location, name, school, reason, address, postcode, email, telephone, town, county, state, country)
VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,'','')',
sqlEscape($_GET['location']),
sqlEscape($_GET['name']),
sqlEscape($_GET['school']),
sqlEscape($_GET['reason']),
sqlEscape($_GET['address']),
sqlEscape($_GET['postcode']),
sqlEscape($_GET['email']),
sqlEscape($_GET['telephone']));
if (!mysql_query($sql,$con)){
die('Error: ' . mysql_error());
}
header('Location: thankyou.php');
mysql_close($con)
?>
并且在修复此编译时错误之后,您将得到另一个运行时“参数太少”错误。以下答案描述了如何修复它。 – kstep
谢谢,这有帮助。现在就开始工作了。感谢所有给我建议和帮助的人。我很感激。 –