- 浏览: 246313 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
nodonkey:
貌似还是不行,再等等吧,amfphp要出2.0了
amfphp1.9与php5.3.X版本不兼容 -
live711:
请问amfphp与php5.3.X搭配能用了吗?
amfphp1.9与php5.3.X版本不兼容 -
zhousheng193:
非常感谢!
安装flash player debug版本遇到的一些问题 -
sp42:
谢谢提示,我遇到的也是不能加密,用MAC地址代替之。
DI-624+A路由器韧体升级解决经常掉线的问题(转) -
心似海:
不错,要挖去了,哈哈
深入sql之merge into
Q:
i m getting this bug.. and i still cant understand why this happening..??
here is my php code
<?php $query1 = "call new_user('$cardDigits','$cardNo','$amount','$traiff','','','','','$creator',@_lastname,'$customer','$firstName','$email','0','0')"; $result1 = mysql_query($query1) or die('query_error'.''.mysql_error()); $lastname = mysql_fetch_row($result1); // Generate New User $query2 = "genrate_user('$lastname[0] ','$creator')"; echo $query2; $result2 = mysql_query($query2) or die('query_error1'.''.mysql_error());Procedures are working fine..!!!
1st Procedure generate the
$lastname
which is the input parameter of second Procedure..!!!!!
when
i print or echo the 2nd procedure.. its run fine at mysql.. but through php its
throughing error Commands out of sync; you can't run this command
now
Help me guys..!!!
Posts:
1.
Hey.
The old MySQL extension was never built to run procedures, even tho
it *can* be used to do so. You should be using the Improved MySQL
extension if you are planing to use features like Stored Procedures.
The
problem you are facing, "Commands out of sync", is caused by unused result sets
left over by your procedure. When you call your first procedure, the result sets
are buffered until you use them. However, you only use one set, and you didn't
even free it before moving on to the second query. You need to free the buffered
result sets before moving on:
It is best to create a function, or a
method, to do this. No need to repeat the code over and over.
For
example:
<?php
/** * Calls a Stored Procedure and returns the results as an array of rows. * @param mysqli $dbLink An open mysqli object. * @param string $procName The name of the procedure to call. * @param string $params The parameter string to be used * @return array An array of rows returned by the call. */ function c_mysqli_call(mysqli $dbLink, $procName, $params="") { if(!$dbLink) { throw new Exception("The MySQLi connection is invalid."); } else { // Execute the SQL command. // The multy_query method is used here to get the buffered results, // so they can be freeded later to avoid the out of sync error. $sql = "CALL {$procName}({$params});"; $sqlSuccess = $dbLink->multi_query($sql); if($sqlSuccess) { if($dbLink->more_results()) { // Get the first buffered result set, the one with our data. $result = $dbLink->use_result(); $output = array(); // Put the rows into the outpu array while($row = $result->fetch_assoc()) { $output[] = $row; } // Free the first result set. // If you forget this one, you will get the "out of sync" error. $result->free(); // Go through each remaining buffered result and free them as well. // This removes all extra result sets returned, clearing the way // for the next SQL command. while($dbLink->more_results() && $dbLink->next_result()) { $extraResult = $dbLink->use_result(); if($extraResult instanceof mysqli_result){ $extraResult->free(); } } return $output; } else { return false; } } else { throw new Exception("The call failed: " . $dbLink->error); } } } ?>
Which you could use like:
<?php header('content-type: text/plain'); $dbLink = new mysqli('localhost', 'usr', 'pwd', 'dbname'); // Execute the first call echo "\n--- FIRST CALL ---\n"; $result = c_mysqli_call($dbLink, 'TestProc', "2, 'second param'"); if($result) { echo "Output: \n"; foreach($result as $_row) { echo " " . $_row['something'] . "\n"; } } // Execute the second call echo "\n--- SECOND CALL ---\n"; $result = c_mysqli_call($dbLink, 'TestProc', "3, 'second param'"); if($result) { echo "Output: \n"; foreach($result as $_row) { echo " " . $_row['something'] . "\n"; } } ?>
Hope that helps.
Q:
If it only matters to free the buffered result set..!!!!
You would have to be able to fetch multiple result sets, and I don't see a way to do that with the mysql_ functions. It would need to implement the mysql_next_result() function of the MySQL API.
Like I say, the mysql extension was not built to be used with procedures. It was built for MySQL 3, but stored procedures weren't introduced until MySQL 5. The Improved MySQL extension was created to address these sort of incompatibilities.
Any specific reason you do not want to switch over?
i uncommented the extension=php_mysqli.dll in php.ini
also check mysqli dll files in ext folder..
but still i m unable to install mysqli...
every time i got this error Class 'mysqli' not found
- Put the DLL into the ext/ directory.
- Add/Uncomment the "extension=xxx.dll" line in the config.
- Restart Apache.
- ... and your done.
If that fails, the most common causes are:
- You are editing the incorrect php.ini file.
- Windows can not find the ext/ directory. Or, more accurately, it doesn't know it is supposed to look in the PHP directory.
- Prerequisites for the extension are missing. (Shouldn't be the case for you, seeing as the other MySQL extension is working.)
- You are using Windows! (Joking... kind of ;-)
stupid of me..!! actually i m using Nusphere at my php IDE..!!!
i dont know tht Nushpere also have php.ini.. in it is commented mysqli.dll
i un comment that and now its working..!!
i have a question regarding mysqli...!!!
if i made my config file in mysql...!! than can i use mysqli functions..!!!
i mean is it necessary to make connection with mysqli extension to use mysqli function..!!!
thanks to u bro..!!!
but in coding i made two config file.. one with mysql other with msqli..!!!
<?php $query1 = "call new_user('$cardDigits','$cardNo','$amount','$traiff','','','','','$creator',@_lastname,'$customer','$firstName','$email','0','0')"; $result1 = mysqli_query(,$mysqli,$query1) // here i made change $lastname = mysqli_fetch_row($result1); // here i made change // Generate New User $query2 = "genrate_user('$lastname[0] ','$creator')"; echo $query2; $result2 = mysql_query($query2) or die('query_error1'.''.mysql_error());thats it..!!
can u give link to basic tutorial of mysqli..?
i will appreciate that.!!
<!-- google_ad_section_end -->
发表评论
-
nginx重启脚本 (平滑重启nginx)
2011-05-19 17:07 2455nginx重启脚本 (平滑重启nginx) ... -
Xcache 使用笔记
2011-02-22 18:32 1698转自:http://www.cnrui.cn/blog/art ... -
三大WEB服务器对比分析(apache ,lighttpd,nginx)
2011-02-22 17:47 2269本文转自:http://www.blogjava.ne ... -
三款免费的PHP加速器:APC、eAccelerator、XCache比较
2011-02-22 17:44 1221本文转载自:http://killker.com/bl ... -
amfphp1.9与php5.3.X版本不兼容
2011-02-18 13:58 3321damned,昨天花了一天时间 ... -
在PHP语言中使用JSON
2011-01-20 19:29 1121作者: 阮一峰 http://www.ruanyif ... -
[转载]50点提高PHP编程效率
2011-01-17 19:09 916这些总结很 实用,希 ... -
php could not find driver
2011-01-11 18:10 1978在调试一个PHP程序时,报了这个错误, could no ... -
linux下执行php文件发现Could not open input file
2010-11-04 13:51 2402在linux下通过svn更新了一个php文件,目的是想通过执行 ... -
PHP call mysql stored procedure
2010-09-20 18:12 1290Before you installed the php_my ... -
学习 JpGraph心得以及一些常见问题解决
2010-09-13 00:28 13489安装JpGraph 的安装十分简便 :到 http: ... -
LAMP最小优化
2010-09-11 17:57 1106原文地址:http://www.blogk ... -
cURL使用心得(转)
2010-09-11 17:47 2883原文地址:http://www.blogkid.net/arc ... -
curl使用介绍2
2010-09-11 17:43 884原帖:http://www.uican.com.c ... -
PHP中CURL使用说明(转)
2010-09-11 17:13 1330转自:http://www.uican.com.c ... -
PHP内存溢出Allowed memory size of 解决办法
2010-08-03 18:21 9597以前追踪过这个问题,但是那个时候工具用的不太好,没看的这么 ... -
PHP自定义时间函数
2010-06-30 18:58 17731.php取本月本周或者下月下周的开始到结束时间 &l ... -
PHP Notice: Undefined index: ... 问题的解决方案
2009-12-30 19:05 6113首先,这个不是错误,是warning。所以如果服务器 ... -
php几个数组函数
2009-10-14 15:43 1454数组运用的熟练有时候能解决很多问题。熟悉相关函数就能事半功倍。 ... -
out of dynamic memory in yy_create_buffer() in Unknown on line 0
2009-09-28 09:22 0自己跑的机子上总会出现这个error: PHP Fatal ...
相关推荐
you can't run this command now"错误是一个常见的问题,它通常出现在多条语句连续执行时,由于某些原因导致数据连接的状态不一致,使得MySQL无法正确处理后续的命令。这个错误的根源在于MySQL的C API,当执行...
问题 mysql 查询出现错误 ... you can’t run this command now in your client code, you are calling client functions in the wrong order. This can happen, for example, if you are using mysql
遇上错误「Error: Commands out of sync. Did you run multiple statements at once?」 原来是必须取得result,并执行result.Close()。原理是什么? 2020.10.26 照着的套路,用Go+Gin 把后台的部分重写了一遍,搞了...
MySQL是支持在单个查询字符串中指定多语句执行的,使用方法是给链接指定参数: 代码如下: //链接时设定 mysql_real_connect( …, CLIENT_MULTI_STATEMENTS ... you can’t run this command now 官方推荐的执行语句是这
在使用Django框架进行Web应用开发时,与数据库的交互是至关重要的环节。当你尝试运行`python manage.py migrate`命令来同步数据库模型时,如果遇到`django.db.utils.OperationalError: (1045, "Access denied for ...
CONFIG_SYS_MAXARGS,是否允许重复执行是 1,执行函数是 do_help,使用信息是 "print command description/usage",详细使用信息是 "- print brief description of all commands\n help command ...\n - print ...
pycharm中导入模块错误时,提示:Try to run this command from the system terminal. Make sure that you use the correct version of ‘pip’ installed for your Python interpreter located atpycharm工作路径。...
telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss 老师测评网址 http://172.16.0.198:8080/poll/ 各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ 一、注意...
Welcome to the Command Reference.This reference contains a complete dictionary of detailed command descriptions, arranged in alphabetical order. It is the definitive resource for correct command ...
November 13 2017:Can't run Cheat Engine There is apparently some malware going around that blocks execution of Cheat Engine (Saying file missing, check filename, etc...) If you have been a victim of ...
The LLDB command command regex acts much like command alias, except you can provide a regular expression for input which will be parsed and applied to the action part of the command. 10. Assembly ...
You don't need to run idf.py build before running idf.py flash, idf.py flash will automatically rebuild anything which needs it. Viewing Serial Output The idf.py monitor target uses the idf_monitor ...
run even if you don't have a co-processor. If you have a coprocessor and want batchnet to run faster, which may be especially important in training, you can recompile batchnet.c using the 80x87 ...
- Corrected a problem where the loopback sound test could run out of memory if run for several days. Release 5.3 build 1013 WIN32 release 31 December 2007 - Improved the reporting of ...
It can be run in interactive mode, or can automatically parse a list of commands from a file. Example LSql queries are: SELECT field1,field2 WHERE +field1:value This command will display two ...
This feature allows you to select which commands to enable in the Visual Studio IDE. Point to the Tools menu, then click Options. Expand the PowerCommands options, then click Commands. Check the ...
7)....Added: Streaming unpacked debug info into temporal files instead of memory - this greatly reduces run-time application memory usage at cost of slightly slower exception processing. This also ...