mysql - Pass on variable sql queries in php -


This query works when phpMyAdmin is entered, but I can not work in PHP:

SET @cnt = 0;

This is the code I have tried:

  $ mysqli = new MyScilli ($ dBhost, $ dbuser, $ dbpass, $ dbname); $ ResSrt = $ mysqli- & gt; Query ("SET @cnt = 0; UPDATE Group no command" SET command = @cnt: = (@ cnt + 1) "); Error if performing ("$ $ ResSrt") {echo "query": ("$ Mysqli-> errno.") ". $ Mysqli- & gt; Error; }   

Here is the error message:

Error executing query: (1064) You have an error in your SQL syntax; To use the closest 'UPDATE groups, check the manual related to your MySQL server version for the correct syntax SET ordering = @cnt: = (@ cnt + 1) according to the name' line1 '

Any ideas how to fix this?

Simple reason:

In

  SET @cnt = 0; Set the command of the SET = @ cnt: = (@ cnt + 1) by name ""   

You can enter single $ mysqli-> The query is attempting to execute 2 queries function.

  • SET as the first query
  • Another query as update

    mysqli _ have multiple queries in your single $ mysqli- & gt; Do not allow to run through the query, this is the reason that its security and sql_injections are preferred as the option to stop

    split them into two separate questions and you can go! !)

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -