Mysql error 2014 commands out of sync

mysql error 2014 commands out of sync

The message indicates that MYSQL database considers this wrong command execution order. The reason is that after the execution of MYSQL's stored. A Database Error Occurred ————————— Error Number: 2014. Commands out of sync; you can't run this command now — The query after your procedure call —. An error occurred while performing operation 'sqlPrepareWithOptions' status='-9'. Details: UDA-SQL-0107 A general exception has occurred during. mysql error 2014 commands out of sync

stored procedures - MySQL error #2014 - Commands out of sync; you can't run this command now

842 votes

14 answers

Get the solution ↓↓↓

I am using MySQL and I am defining a stored procedure like this:

When I try to execute that procedure I get this error:

What does this mean and what am I doing wrong?

Undefined asked




257

votes

Answer

Solution:

From Manual

C.5.2.14. Commands out of sync
If you get in your client code, you are calling client functions in the wrong order.

This can happen, for example, if you are using and try to execute a new query before you have called. It can also happen if you try to execute two queries that return data without calling or in between.

This post (taken from here)

I've solved that problem. I use MySQL-Fron instead MySQL Query browser. And everything works fine.

makes me think that it's not a server or database problem but a problem in the tool you're using.

Undefined answered

Link to answer



80

votes

Answer

Solution:

I was able to reproduce this error with MySQL and phpmyadmin:

enter image description here On this version of MySQL:

With the following SQL run through the phpmyadmin query window:

I couldn't get the error to happen through the MySQL terminal, so I think it's a bug with phpmyadmin.

It works fine on the terminal:

I think the bug has something to do with changing the delimiters mid-query within phpmyadmin.

Workaround: Slow down there, cowboy, and run your SQL statements one at a time when using phpmyadmin. phpmyadmin is "single task bob", he can only do one job.

Undefined answered

mysql error 2014 commands out of sync Link to answer



979

votes

Answer

Solution:

In my case, mysql error 2014 commands out of sync, I had the following structure in my stored procedure:

The problem relies here: I removed the semi colon and replaced it with the delimiter like this:

And it's now solved!

Undefined answered

Link to answer



843

votes

Answer

Solution:

The possible reason is that mysql client in your code is not thread safe, i encountered the same error when I call mysqldb in python, I have one mysql interface, used in 2 threads, the error happens. In this situation, you need to create more mysql interfaces along with threads.

Undefined answered

Link to answer






727

votes

Answer

Solution:

Undefined answered

Link to answer



242

votes

Answer

Solution:

Suppose that when you created the stored procedure you stored it in database named to CALL the procedure. Go to your localhost DB and:

Where is the name of your procedure.

Undefined answered

Link to answer



922

votes

Answer

Solution:

You forgot to use the 'Begin' keyword, and during compilation MySQL is confused, this should work:

Undefined answered

Link to answer



30

votes

Answer

Solution:

I also encountered this problem with mysql error 2014 commands out of sync C API.

I found the solution with the last example above, which speaks of delimiters.

My code executes a stored procedure then tests the return. I use correctly the mysql_free_result().

Since I have not added a select clause "into" in the procedure, this error occurred.

The last example above is in the same case.

I have deleted the select and since it's ok.

Alex

Undefined answered

Link to answer



585

votes

Answer

Solution:

I just got the same error from phpMYadmin when calling a user function I'm working on.

mysql console says however:

.which is absolutely correct, it was misspelled in the field list, so a statement was referencing an undefined variable.

I'd have to conclude that

from phpMYadmin is a rather non-specific error, than in many cases, if not most, is just obscuring the real problem, and one should not spend too much time trying to make sense out of it.

Undefined answered

Link to answer



112

votes

Answer

Solution:

You have this problem apparently because both statements are executing simultaneously. The only workaround I have found is to close the connection after the sp and execute the other statement on a new one. Read about it here.

Undefined answered

Link to answer



542

votes

Answer

Solution:

This was happening to me because a function within an procedure gave a value back that wasn't allocated to a variable.

The solution was:

Undefined answered

Link to answer



452

votes

Answer

Solution:

It seems there are multiple sources for this issue. None of the posted answers worked in my case, I found that in my case I had selects and updates on a table in my stored procedure, the same table had an update trigger which was being triggered and sending the procedure into an infinite loop. Once the bug was found the error 9th company roots of terror rus torrent away.

I also reproduced the issue in the case where I had a select which was calling a function which modified the table. It makes sense that these types of recursive calls could create issues. The issues were solved by updating a tmp table and at the end updating the original table from the tmp table.

Undefined answered

Link to answer



135

votes

Answer

Solution:

I had this error just now due to a code change that re-used db connections in Python. Reverting the code to establish a DB connection for each SQL query resolved the problem.

Undefined answered

Link to answer



People are also looking for solutions to the problem: undefined array key
Source

Share


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question


Similar questions

Find the answer in similar questions on our website.

739javascript - Why this form won't call the JS function? (trying to get an autocomplete form field calling a MySQL database with a PHP script and AJAX)

462datetime - How to get start and end date of months of a given range of date in php

912mysql - Fatal error: Call to undefined method Action::execute() /home/public_html/system/engine/event.php on line 62

106Incorrect Webpage Output for PHP exec running bash script for audtool (part of Audacious)

794php - magento pressing on the update button on the product page adds item instead of changing item

810php - Save in MySQL database an image stored on Xampp localhost dierctory whithout form

179datetime - PHP time section of date as text

851javascript - Convert indian standard time to mysql datetime format using php

624iterator - Understanding OuterIterator Interface PHP

872php - how to calculate age that stored in database over current date?

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.




About the technologies asked in this question

PHP

PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites. The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/


MySQL

DBMS is a database management system. It is designed to change, search, add and delete information in the database. There are many DBMSs designed for similar purposes with different features. One of the most popular is MySQL. It is a software tool designed to work with relational SQL databases. It is easy to learn even for site owners who are not professional programmers or administrators. MySQL DBMS also allows you to export and import data, which is convenient when moving large amounts of information.
https://www.mysql.com/


HTML

HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet. Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/



Welcome to programmierfrage.com

Welcome to programmierfrage.com

programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, mysql error 2014 commands out of sync, web development, website creation and website administration.

Get answers to specific questions

Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.

Help Others Solve Their Issues

Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.

Foo +-----+

Issues

django 1.3 running under Ubuntu 10.04 LTS x86_64 with python 2.6.5-1ubuntu6, python-mysqldb 1.2.2-10build1, mysql 5.1.41-3ubuntu12.10

Here is a trivial stored procedure:

mysql> delimiter $$ mysql> create procedure dummy() -> begin -> select 'Foo'; -> end -> $$ Query OK, 0 rows affected (0.00 sec) mysql> delimiter ; mysql> call dummy(); +-----+

Mysql Error 2014 Commands Out Of Sync You Cant Run This Command Now
















More Answers Related Mysql Error 2014 Commands Out Of Sync You Cant Run This Command Now

Mysql error #2014 - Commands out of sync; you can't run …

1 week ago Nov 22, 2018  · When I'm trying to execute this stored-procedure from phpmyadmin I get the following error: Unrecognized keyword. (near "ON" at position 25) SQL query: Edit Edit SET FOREIGN_KEY_CHECKS = ON; MySQL said: Documentation #2014 - Commands out of sync; you can't runthiscommandnow

Reviews: 8

Show details

See also: Php Sql

Bug #58876 Error: 2014 Commands out of sync; you can't …

1 week ago Hi, What I found is that I needed to call mysql_stmt_fetch (stmt); until it returned 100 (i.e. MYSQL_NO_DATA). Even-though there was only one row of data returned, it was not in the proper state because it had not gotten to MYSQL_NO_DATA. So I added extra while () loop after the initial call to get to MYSQL_NO_DATA. All worked well after.

Show details

See also: Mysql Sql

MySQL Bugs: #85324: Error Code: 2014. Commands out …

1 day ago Commands out of sync; you can't runthiscommandnow. How to repeat: Running the simplest query against the database. [7 Mar 2017 5:33] MySQL Verification Team

Show details

See also: Database

2014 – Commands out of sync; you mysql error 2014 commands out of sync run this command now

1 week ago Aug 04, 2011  · 2014 – Commands out of sync; you can’t runthiscommandnow. Now that can be a really annoying error! It happens when querying stored procedures in phpMyAdmin as mysqli seems to return 2 sets of results opposed to the usual 1 that mysql returns. You cannot call anything else until you have “flushed” or “cleared” the second result.

Show details

See also: Php Mysql Sql

2014 Commands out of sync; you can't run this command …

1 day ago Jul 26, 2007  · The stored procedure is built to do : 1- insert into a table. 2- get last id inserted and return it in a select statement ( select. last_inserted_id (); ) And the PHP is located in to computers the first is a 5.2.3 which is. the Dev Server and …

Show details

MySQL :: Error No: 2014, Error: Commands out of sync; …

1 day ago Apr 24, mysql error 2014 commands out of sync, 2009  · Error: Commands out of sync; you can't runthiscommandnow So please let me know if any body knows the solution of this, mysql error 2014 commands out of sync. Navigate: Previous Message • Next Message

Show details

MySQL error #2014 - Commands out of sync; you can't …

5 days ago I knowyou do not get any more maintenance on this project, but if anyone can, I'll be grateful! The text was updated successfully, but these errors were encountered: Sign up for free to join this conversation on GitHub.

Show details

See also: Date

在mysql运行while循环函数,报错2014 commands out of sync; …

2 days ago Aug 24, mysql error 2014 commands out of sync, 2022  · CSDN问答为您找到在mysql运行while循环函数,报错2014commandsout of sync; you can't runthiscommandnow相关问题答案,如果想了解更多关于在mysql运行while循环函数,报错2014commandsout of sync; you can't runthiscommandnowmysql、sql 技术问题等相关问答,请访问CSDN问答。

Show details

See also: Mysql Sql

Please leave your answer here:

Commands out of sync; you can't run this command now

If you use mysqli's query method to get the result, you will get an error: Ml 1640 internal error false out of sync; you can't run this command now sss

Stored procedure:

CREATE PROCEDURE test1() begin drop table if exists tb1; mysql error 2014 commands out of sync create table tb1 ( val int not null )engine = innoDB; insert into tb1(val) values(1),(2),(3); select * from tb1; end
<?php $mysqli = new mysqli("localhost", "root", "sbqcel", "test"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $result = null; $mysqli->autocommit(FALSE); if(!($result = $mysqli->query( "call test1();"))) { b8 end-to-end error echo mysqli_error($link); $mysqli->rollback(); } $mysqli->commit(); print 'Result1:'; while ($row = $result->fetch_row()) { printf ("%s <br />", $row[0]); } $result->close(); mysqli_free_result($result); echo 'result2:<br />'; if ($result2 = $mysqli->query("select val from tb1;")) { while ($row = $result2->fetch_row()) { printf ("%s <br />", $row[0]); } $result2->close(); } else { echo $mysqli->error; } mysqli_free_result($result2); mysqli_close($link); ?>

After executing the above code, the above error will appear. The message indicates that MYSQL database considers this wrong command execution order. The reason is that after the execution of MYSQL's stored procedure, in addition to returning the actual result set, it also returns the transition state of the stored procedure execution. The above code only processes the first result set, and the second result set is not released.
When a stored procedure returns a resultset, MySQL returns at least two resultsets: first for the SELECT CALL inside the stored procedure. 2ndfor the call of the stored procedure itself (2nd usually is only an OK or ERR packet).

To solve this problem, you need to use mysqli's multi query method to traverse all result sets and release them. The mysql error 2014 commands out of sync is as follows:

Extract the key points into a method, as follows:

In this way, you can call this method when you want to use the stored procedure

It can be seen from another article of the author that there will be a relatively complete process:

MySql error1337 Variable or condition declaration after cursor or handler declaration

In this way, PHP and MySql are available

Reference resources: Commands out of sync; you can't run this command now

0 Comments

Leave a Comment