Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.