Jump to content

Trouble with MySQL query


Perad

Recommended Posts

Is there someway I can clean this query to make it work with MySQL, I think it is going wrong because mysql is interpretting the - in the item code as a minus.

 

Query is the following.

 UPDATE p_MUM - INOPT SET mconnec = 'USB',
itemcode = 'MUM-INOPT',
item = 'MicroSoft IntelliMouse Optical - PS2/USB',
model = 'Microsoft D58-00017',
tm = 'Optical',
mwireless = 'No',
tr = '800dpi',
mdocking = 'Yes',
mrecharge = '',
mbuttons = '5',
mscroll = 'Yes',
weight = 'PS2, USB 1.1/2.0',
price = '0.50',
WHERE itemcode = 'MUM-INOPT' 

 

Error starts at '-INOPT" so it must be the - character.

 

My PHP is...

 

foreach($_POST as $K => $V)
				{
					//may want to clean $K as well
					if ($K == "submit") {
					} else {	
						if ($_GET['page'] == "process") {			
							$databaseentry .= $K . "='" . $this->cleanString($V). "', ";
						} else {			
							$Clean[$K] = $this->cleanString($V);
						}
					}
				}
				if ($_GET['page'] == "process") {			

				} else {
					$fields = implode(",",array_keys($Clean));
					$Values = implode("','",$Clean);
				}
				if ($_GET['page'] == "process") {
					$sql = "UPDATE p_$cleanpart SET $databaseentry WHERE itemcode='".$_POST['itemcode']."'";
					echo $sql;
				} else {
					$sql = "INSERT INTO p_$cleanpart ($fields) VALUES ('$Values')";							
				}	
				$result = mysql_query($sql) or die(mysql_error());	

Link to comment
https://forums.phpfreaks.com/topic/66660-trouble-with-mysql-query/
Share on other sites

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.