Hi,
This is the error I get when trying to update the dedicated set for my database;
Parse error: parse error, unexpected '=' in C:\Audit\postupdate.php on line 26
Here is the code;
<?php
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;
$db = mysql_connect("localhost","giacom-admin","snooker") or die("Problem connecting");
mysql_select_db("audit") or die("Problem selecting database");
echo "Record updated<br><a href=\"update.php\">click here</a> to update another record<br>";
query="UPDATE dedicated set ".
"title= \"".$formVars["title"]."\",".
"customer= \"".$formVars["customer"]."\",".
"type= \"".$formVars["type"]."\",".
"serial= \"".$formVars["serial"]."\",".
"os= \"".$formVars["os"]."\",".
"oslicense= \"".$formVars["oslicense"]."\",".
"oemfull= \"".$formVars["oemfull"]."\",".
"processor= \"".$formVars["processor"]."\",".
"memory= \"".$formVars["memory"]."\",".
"IP= \"".$formVars["IP"]."\",".
"disksize= \"".$formVars["disksize"]."\",".
"graphics= \"".$formVars["graphics"]."\",".
"networkcard= \"".$formVars["networkcard"]."\",".
"software= \"".$formVars["software"]."\",".
"software2= \"".$formVars["software2"]."\",".
"software3= \"".$formVars["software3"]."\",".
"software4= \"".$formVars["software4"]."\",".
"software5= \"".$formVars["software5"]."\",".
"software6= \"".$formVars["software6"]."\",".
"software7= \"".$formVars["software7"]."\",".
"software8= \"".$formVars["software8"]."\",".
"software9= \"".$formVars["software9"]."\",".
"software10= \"".$formVars["software10"]."\",".
"license= \"".$formVars["license"]."\",".
"license2= \"".$formVars["license2"]."\",".
"license3= \"".$formVars["license3"]."\",".
"license4= \"".$formVars["license4"]."\",".
"license5= \"".$formVars["license5"]."\",".
"license6= \"".$formVars["license6"]."\",".
"license7= \"".$formVars["license7"]."\",".
"license8= \"".$formVars["license8"]."\",".
"license9= \"".$formVars["license9"]."\",".
"license10= \"".$formVars["license10"]."\",".
"location= \"".$formVars["location"]."\",".
"motherboard= \"".$formVars["motherboard"]."\" WHERE asset = \"".$formVars["asset"]."\"";
mysql_query($query);
mysql_close($db);
?>
and here is line 26 from the above code;
query="UPDATE dedicated set ".
Please help!!!
PHP parse error, please help!!
Moderator: General Moderators
- mhouldridge
- Forum Contributor
- Posts: 267
- Joined: Wed Jan 26, 2005 5:13 am
- mhouldridge
- Forum Contributor
- Posts: 267
- Joined: Wed Jan 26, 2005 5:13 am
as the column names appear to be the same as the keys in formvars...
Code: Select all
$ignore = array ('asset');
$query = "UPDATE whatever SET ";
foreach($formvars as $key => $val)
{
if (!in_array($key, $ignore)
{
$val = mysql_escape_string($val);
$query .= "$key='$val', ";
}
}
// chop off last ,
$query = rtrim($query, ", ");
$asset = mysql_escape_string($formvarsї'asset'];
$query .= "WHERE asset='$asset'";