I keep researching and researching this, but can't find the answer. It's probably simple.
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.
Why is this causing a syntax error?
$query = "SET @r := 1000; UPDATE discography SET pagename = (@r := @r + 1) ORDER BY RAND()";
mysql_query($query);
Yeilds:
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
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.
Edit
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:
$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);