title: MySQL randomly generated numbers with letters prefix, and an error using variables?
body: <p>I keep researching and researching this, but can't find the answer.  It's probably simple.</p>
  
  <p>I'd like to update my fields with a randomly generated number using a string prefix.  Example: item283940.  Preferably I'd like to start at 1000 and just increment up.  I seem to have most of the query for the random numbers down, however it looks like I'm missing something.</p>
  
  <p>Why is this causing a syntax error?</p>
  
  <pre><code>$query = "SET @r := 1000; UPDATE discography SET pagename = (@r := @r + 1) ORDER BY RAND()";
  
  mysql_query($query);
  </code></pre>
  
  <p>Yeilds:</p>
  
  <pre><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 discography SET pagename = (@r := @r + 1) ORDER BY RAND()' at line 1
  </code></pre>
  
  <p>And once the error is sorted out, I'd like to know how to add the prefix "item" at the beginning of the variable.  Many thanks in advance.</p>
  
  <p><em><strong>Edit</em></strong></p>
  
  <p>It looks like my server uses an older version of PHP so I can't use mysqli.  In terms of solving my other issues, it's inefficient but this worked for my needs:</p>
  
  <pre><code>$setit = "SET @r := 1000";
  $changenames = "UPDATE discography SET pagename = (@r := @r + 1) ORDER BY RAND()";
  $prepend = "UPDATE discography SET pagename=CONCAT('item',pagename)";
  mysql_query($setit);
  mysql_query($changenames);
  mysql_query($prepend);
  </code></pre>