SQL Error when inserting record
when attempting update record in dreamweaver, receiving following error:
"you have error in sql syntax; check manual corresponds mysql server version right syntax use near ' organization, office, department, phone, emailaddress, jobtitle, `officialmaili' @ line 1"
i suspect there problem sql statements i'm not programmer , hoping take @ script , see if there obvious problem sql statements.
thank can provide , here entire script page:
<?php require_once('connections/group4.php'); ?>
<?php
if (!function_exists("getsqlvaluestring")) {
function getsqlvaluestring($thevalue, $thetype, $thedefinedvalue = "", $thenotdefinedvalue = "")
{
if (php_version < 6) {
$thevalue = get_magic_quotes_gpc() ? stripslashes($thevalue) : $thevalue;
}
$thevalue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($thevalue) : mysql_escape_string($thevalue);
switch ($thetype) {
case "text":
$thevalue = ($thevalue != "") ? "'" . $thevalue . "'" : "null";
break;
case "long":
case "int":
$thevalue = ($thevalue != "") ? intval($thevalue) : "null";
break;
case "double":
$thevalue = ($thevalue != "") ? doubleval($thevalue) : "null";
break;
case "date":
$thevalue = ($thevalue != "") ? "'" . $thevalue . "'" : "null";
break;
case "defined":
$thevalue = ($thevalue != "") ? $thedefinedvalue : $thenotdefinedvalue;
break;
}
return $thevalue;
}
}
$editformaction = $_server['php_self'];
if (isset($_server['query_string'])) {
$editformaction .= "?" . htmlentities($_server['query_string']);
}
if ((isset($_post["mm_update"])) && ($_post["mm_update"] == "form1")) {
$updatesql = sprintf("update saar set supervisor_supervisornumber=%s, typeofrequest=%s, `date`=%s, systemname=%s, systemlocation=%s, justificationforaccess=%s, typeofaccessrequired=%s, userrequiredaccess=%s, verificationofneedtoknow=%s, accessexpdate=%s, individual_individualnumber=%s saarnumber=%s",
getsqlvaluestring($_post['supervisor_supervisornumber'], "int"),
getsqlvaluestring($_post['typeofrequest'], "text"),
getsqlvaluestring($_post['date'], "text"),
getsqlvaluestring($_post['systemname'], "text"),
getsqlvaluestring($_post['systemlocation'], "text"),
getsqlvaluestring($_post['justificationforaccess'], "text"),
getsqlvaluestring($_post['typeofaccessrequired'], "text"),
getsqlvaluestring($_post['userrequiredaccess'], "text"),
getsqlvaluestring($_post['verificationofneedtoknow'], "text"),
getsqlvaluestring($_post['accessexpdate'], "text"),
getsqlvaluestring($_post['individual_individualnumber'], "int"),
getsqlvaluestring($_post['saarnumber'], "int"));
mysql_select_db($database_group4, $group4);
$result1 = mysql_query($updatesql, $group4) or die(mysql_error());
$updategoto = "view.php?saarnumber=" . $row_rssaar['saarnumber'] . "";
if (isset($_server['query_string'])) {
$updategoto .= (strpos($updategoto, '?')) ? "&" : "?";
$updategoto .= $_server['query_string'];
}
header(sprintf("location: %s", $updategoto));
}
$varsupervisor_rssaar = "2";
if (isset($_get['saarnumber'])) {
$varsupervisor_rssaar = $_get['saarnumber'];
}
mysql_select_db($database_group4, $group4);
$query_rssaar = sprintf("select * supervisor, saar, individual saarnumber = %s , saar.supervisor_supervisornumber = supervisor.supervisornumber , individual.individualnumber = saar.individual_individualnumber", getsqlvaluestring($varsupervisor_rssaar, "int"));
$rssaar = mysql_query($query_rssaar, $group4) or die(mysql_error());
$row_rssaar = mysql_fetch_assoc($rssaar);
$totalrows_rssaar = mysql_num_rows($rssaar);
?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>validate user</title>
<script src="spryassets/sprymenubar.js" type="text/javascript"></script>
<link href="spryassets/sprymenubarhorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.header {
font-size: 36px;
text-decoration: underline;
}
.quote {
font-size: 18px;
font-style: italic;
}
</style>
</head>
<body>
<p><img src="images/ega.png" width="227" height="222" alt="ega" /><span class="header">saar tracking system
</span></p>
<ul id="menubar1" class="menubarhorizontal">
<li><a href="home.php">home</a> </li>
<li><a href="search.php">search</a></li>
<li><a href="contact.php">contact us</a> </li>
</ul>
<p> </p>
<p>user information:</p>
<p> </p>
<form action="<?php echo $editformaction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">typeofrequest:</td>
<td><input type="text" name="typeofrequest" value="<?php echo htmlentities($row_rssaar['typeofrequest'], ent_compat, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">date:</td>
<td><input type="text" name="date" value="<?php echo htmlentities($row_rssaar['date'], ent_compat, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">systemname:</td>
<td><input type="text" name="systemname" value="<?php echo htmlentities($row_rssaar['systemname'], ent_compat, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">systemlocation:</td>
<td><input type="text" name="systemlocation" value="<?php echo htmlentities($row_rssaar['systemlocation'], ent_compat, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">justificationforaccess:</td>
<td><input type="text" name="justificationforaccess" value="<?php echo htmlentities($row_rssaar['justificationforaccess'], ent_compat, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">typeofaccessrequired:</td>
<td><input type="text" name="typeofaccessrequired" value="<?php echo htmlentities($row_rssaar['typeofaccessrequired'], ent_compat, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">userrequiredaccess:</td>
<td><input type="text" name="userrequiredaccess" value="<?php echo htmlentities($row_rssaar['userrequiredaccess'], ent_compat, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">verificationofneedtoknow:</td>
<td><input type="text" name="verificationofneedtoknow" value="<?php echo htmlentities($row_rssaar['verificationofneedtoknow'], ent_compat, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">accessexpdate:</td>
<td><input type="text" name="accessexpdate" value="<?php echo htmlentities($row_rssaar['accessexpdate'], ent_compat, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="update record" /></td>
</tr>
</table>
<input type="hidden" name="saarnumber" value="<?php echo $row_rssaar['saarnumber']; ?>" />
<input type="hidden" name="supervisor_supervisornumber" value="<?php echo htmlentities($row_rssaar['supervisor_supervisornumber'], ent_compat, 'utf-8'); ?>" />
<input type="hidden" name="individual_individualnumber" value="<?php echo htmlentities($row_rssaar['individual_individualnumber'], ent_compat, 'utf-8'); ?>" />
<input type="hidden" name="mm_update" value="form1" />
<input type="hidden" name="saarnumber" value="<?php echo $row_rssaar['saarnumber']; ?>" />
</form>
<p> </p>
<p class="quote">"be polite, professional, have plan kill meet" general james mattis</p>
<p> </p>
<script type="text/javascript">
var menubar1 = new spry.widget.menubar("menubar1", {imgdown:"spryassets/sprymenubardownhover.gif", imgright:"spryassets/sprymenubarrighthover.gif"});
</script>
</body>
</html>
<?php
mysql_free_result($rssaar);
mysql_free_result($rssupervisor);
?>
the weird thing error message lists fields don't correspond sql statements or fields in form. sure copied right code?
More discussions in Dreamweaver support forum
adobe
Comments
Post a Comment