当我尝试更新到数据库时出现错误。错误说:
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 6 行的 'WHERE company_id='2'' 附近使用正确的语法
第 6 行与什么相关以及如何解决?
<?php
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php
// Parse the form data and update company information to the system
if (isset($_POST['company_name'])) {
$pid = mysql_real_escape_string($_POST['thisID']);
$company_name = mysql_real_escape_string($_POST['company_name']);
$company_url = mysql_real_escape_string($_POST['company_url']);
$company_username = mysql_real_escape_string($_POST['company_username']);
$company_password = mysql_real_escape_string($_POST['company_password']);
// See if that company name is an identical match to another company in the system
$sql = mysql_query("UPDATE company SET
company_name='$company_name',
company_url='$company_url',
company_username='$company_username',
company_password='$company_password',
WHERE company_id='$pid'") or die(mysql_error());
header("location: company.php");
exit();
}
?>
<?php
// Gather these companies full information for inserting automatically into the edit form below on page
if (isset($_GET['pid'])) {
$targetID = $_GET['pid'];
$sql = mysql_query("SELECT * FROM company WHERE company_id='$targetID' LIMIT 1");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){
$company_id = $row["company_id"];
$company_name = $row["company_name"];
$company_url = $row["company_url"];
$company_username = $row["company_username"];
$company_password = $row["company_password"];
}
} else {
echo "Sorry dude that doesn't exist.";
exit();
}
}
?>