Jump to content

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

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.