Jump to content

[SOLVED] sql error, i cant find it can someone with fresh eyes help me out?


jesushax

Recommended Posts

heres the code

$posts = $_POST;
unset($posts['ID']);

    $SQL = "UPDATE cwi_computers SET";
foreach($posts as $key => $value){
    $SQL .= " `$key`='$value',";
}
$SQL .= rtrim($SQL,",");
$SQL .= " WHERE ID='".$_POST["ID"]."'";
echo "<p>".$SQL."</p>";
mysql_query($SQL) or die(mysql_error());

 

Heres the Output

UPDATE cwi_computers SET `ComputerID`='CWR001', `Location`='On & Off All Sites', `ComputerName`='Alex-Laptop', `CurrentIP`='192.168.10.19', `CurrentUser`='Steve Craker', `OperatingSystem`='Windows Vista Business', `Motherboard`='', `Motherboard_URL`='', `CPU`='Inter Centrino Core 2', `CPU_Speed`='2.26', `Core`='x2', `RAM`='3GB', `RAM_URL`='', `HDD`='320GB', `OpticalDrives`='DVD-RW',UPDATE cwi_computers SET `ComputerID`='CWR001', `Location`='On & Off All Sites', `ComputerName`='Alex-Laptop', `CurrentIP`='192.168.10.19', `CurrentUser`='Steve Craker', `OperatingSystem`='Windows Vista Business', `Motherboard`='', `Motherboard_URL`='', `CPU`='Inter Centrino Core 2', `CPU_Speed`='2.26', `Core`='x2', `RAM`='3GB', `RAM_URL`='', `HDD`='320GB', `OpticalDrives`='DVD-RW' WHERE ID='1'
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE cwi_computers SET `ComputerID`='CWR001', `Location`='On & Off All Sites',' at line 1

 

ive just noticed that the echo of the statement shows that its posting the results twice

anyone know why?

 

Cheers

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.