troubleshooting Question

Wordpress UPDATE Query Syntax

Avatar of Robert Granlund
Robert GranlundFlag for United States of America asked on
WordPressPHPWeb Development
2 Comments2 Solutions475 ViewsLast Modified:
I keep getting an error saying there is something wrong with my syntax at line two.  I'm using wordpress and not 100% sure how to do multiple updates to the wp_postmeta table:
$update_meta_item = $pdo->prepare("
						UPDATE wp_postmeta
						SET meta_value = :price WHERE meta_key = '_regular_price' AND post_id = '$prod_id',
							meta_value = :price WHERE meta_key = '_price' AND post_id = '$prod_id',
							meta_value = :quantity WHERE meta_key = '_stock' AND post_id = '$prod_id'"); 
					
					
					try	{
						$update_meta_item->execute(array(
						':quantity'=>$data[16],
						':price'=>$data[3])) or die(print_r($update_meta_item->errorInfo()));
						echo '<b>'.++$cnt .'</b> -- Product ID: <b>'. $title.' </b> has been updated.<br />';
						
						}
						catch(PDOException $aa) {
   							echo 'ERROR: ' . $aa->getMessage();
						}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros