This query works when entered into phpMyAdmin however I cannot get it to work in PHP:
SET @cnt = 0; UPDATE groupsnumber SET ordering = @cnt := (@cnt+1) ORDER BY name
This is the code I have tried:
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
$resSrt =$mysqli->query("SET @cnt = 0;
UPDATE groupsnumber
SET ordering = @cnt := (@cnt+1) ORDER BY name");
if (!$resSrt)
{
echo "Error executing query: (" . $mysqli->errno . ") " . $mysqli->error;
}
Here is the error message:
Error executing query: (1064) 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 groupsnumber SET ordering = @cnt := (@cnt+1) ORDER BY name' at line 1
Any ideas how to fix this?