title: mysql update on select row number
body: <p>I have next code:</p>
  
  <pre><code>SET @rownum=0;
  UPDATE product_images AS t, (SELECT @rownum:=@rownum+1 rownum, id, rel 
  FROM product_images WHERE product_id='227') AS r
  SET t.rel = r.rownum
  WHERE t.id = r.id
  </code></pre>
  
  <p>This is working excellent in phpmyadmin</p>
  
  <p>BUT ... next code (witch is actually the same) but placed in php code</p>
  
  <pre><code>mysql_query ("
  SET @rownum=0; 
  UPDATE product_images AS t, 
  (SELECT @rownum:=@rownum+1 rownum, product_images.* 
  FROM product_images WHERE product_id='$pid') AS r
  SET t.rel = r.rownum WHERE t.id = r.id ") or die(mysql_error());
  </code></pre>
  
  <p>GIVES ME ERROR : <code>"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 product_images AS t, (SELECT @rownum:=@rownum+1 rownum, product_images.* ' at line 1"</code></p>
  
  <p>PLEASE HELP. THANK YOU.</p>