<i id='jHhrR'><tr id='jHhrR'><dt id='jHhrR'><q id='jHhrR'><span id='jHhrR'><b id='jHhrR'><form id='jHhrR'><ins id='jHhrR'></ins><ul id='jHhrR'></ul><sub id='jHhrR'></sub></form><legend id='jHhrR'></legend><bdo id='jHhrR'><pre id='jHhrR'><center id='jHhrR'></center></pre></bdo></b><th id='jHhrR'></th></span></q></dt></tr></i><div id='jHhrR'><tfoot id='jHhrR'></tfoot><dl id='jHhrR'><fieldset id='jHhrR'></fieldset></dl></div>
    • <bdo id='jHhrR'></bdo><ul id='jHhrR'></ul>
  • <tfoot id='jHhrR'></tfoot>

    <legend id='jHhrR'><style id='jHhrR'><dir id='jHhrR'><q id='jHhrR'></q></dir></style></legend>

    <small id='jHhrR'></small><noframes id='jHhrR'>

        命令行 php mysqli 失败但通过 Web 服务器工作并在本地工作

        Command line php mysqli fails but works via web server and works in local(命令行 php mysqli 失败但通过 Web 服务器工作并在本地工作)
        • <small id='dkP1A'></small><noframes id='dkP1A'>

            <bdo id='dkP1A'></bdo><ul id='dkP1A'></ul>

              1. <legend id='dkP1A'><style id='dkP1A'><dir id='dkP1A'><q id='dkP1A'></q></dir></style></legend>

                  <tbody id='dkP1A'></tbody>
                <i id='dkP1A'><tr id='dkP1A'><dt id='dkP1A'><q id='dkP1A'><span id='dkP1A'><b id='dkP1A'><form id='dkP1A'><ins id='dkP1A'></ins><ul id='dkP1A'></ul><sub id='dkP1A'></sub></form><legend id='dkP1A'></legend><bdo id='dkP1A'><pre id='dkP1A'><center id='dkP1A'></center></pre></bdo></b><th id='dkP1A'></th></span></q></dt></tr></i><div id='dkP1A'><tfoot id='dkP1A'></tfoot><dl id='dkP1A'><fieldset id='dkP1A'></fieldset></dl></div>

                  <tfoot id='dkP1A'></tfoot>
                • 本文介绍了命令行 php mysqli 失败但通过 Web 服务器工作并在本地工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 shell 脚本,它在解析文本文件后调用 php 脚本在数据库中插入记录.当它调用 PHP 脚本时,我得到了找不到 mysqli 的错误:

                  I have a shell script that calls a php script to insert records in database after parsing text file. When it calls the PHP script I get errors that it cannot find mysqli:

                  PHP Fatal error:  Class 'mysqli' not found in /path/to/php/file.php on line 5
                  

                  使用 Nginx 和 PHP-FPM 和 Mysql 5.5.x 在 Macbook Pro 上本地失败,在我将套接字参数添加到 mysqli 调用后,它在本地工作.这适用于本地数据库!

                  This failed in local on Macbook Pro with Nginx and PHP-FPM and Mysql 5.5.x and after I added the socket param to mysqli call, it worked in local. This worked with local db!

                  $mysqli = new mysqli("localhost", "user", "pass", "mydb", 3306, "/tmp/mysql.sock");
                  

                  我部署到安装了 Linux 服务器(CentOS6 安装了 'yum install php' 和 PHP 5.3.x).我更改了与远程 db 服务器的连接,因此删除了/tmp/mysql.sock",因为 db 未在此服务器上运行.

                  I deployed to Linux server (CentOS6 that has 'yum install php' with PHP 5.3.x) installed. I changed the connection to a remote db server so dropped the "/tmp/mysql.sock" because db not running on this server.

                  Shell脚本调用php执行脚本:

                  Shell script calling php to execute script:

                  php -c "/etc/php.ini" -f "/path/to/php/file.php"
                  

                  鉴于我没有在本地运行 mysql,我如何让它识别 mysqli lib 并执行.它在 CentOS6 上.我什至尝试将 mysqli.so 添加到 php.ini 文件并得到以下错误:

                  Given I am not running mysql locally, how do I get it to recognize the mysqli lib and execute. It's on CentOS6. I even tried adding mysqli.so to php.ini file and got following error:

                  [mike@app2 myapp]# php -version
                  PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mysqli.so' - /usr/lib64/php/modules/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
                  PHP 5.3.3 (cli) (built: Feb  2 2012 23:47:49) 
                  Copyright (c) 1997-2010 The PHP Group
                  Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
                  

                  感谢您提供解决此问题的任何帮助.通常我会使用 mysql(query) 但需要 mysqli() 用于脚本中的一些准备好的语句和其他位.

                  Thanks for any help resolving this. Normally I'd use mysql(query) but need mysqli() for some prepared statements and other bits in the script.

                  推荐答案

                  发现mysqli没有安装php,运行如下命令:

                  I found that mysqli was not installed with PHP and ran the following command:

                  >php -i
                  

                  这返回了 phpinfo() 并且发现没有提到 mysqli.然后我运行 'yum' 命令来安装 php-mysqli:

                  This returned the phpinfo() and found no mention of mysqli. I then ran the 'yum' command to install php-mysqli:

                  >yum install php-mysqli
                  

                  在此之后脚本成功运行.希望这对可能遇到类似情况的其他人有所帮助.

                  After this the script worked successfully. Hope this helps others that might run into similar.

                  这篇关于命令行 php mysqli 失败但通过 Web 服务器工作并在本地工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Converting string to MySQL timestamp format in php(在php中将字符串转换为MySQL时间戳格式)
                  datetime to timestamp(日期时间到时间戳)
                  PHP timestamp date to user timezone(PHP时间戳日期到用户时区)
                  Converting TIMESTAMP to unix time in PHP?(在 PHP 中将 TIMESTAMP 转换为 unix 时间?)
                  Convert ISO 8601 to unixtimestamp(将 ISO 8601 转换为 unixtimestamp)
                  Finding days between 2 unix timestamps in php(在php中查找2个unix时间戳之间的天数)

                      <bdo id='7Doi2'></bdo><ul id='7Doi2'></ul>
                      <tfoot id='7Doi2'></tfoot>
                            <tbody id='7Doi2'></tbody>

                          • <i id='7Doi2'><tr id='7Doi2'><dt id='7Doi2'><q id='7Doi2'><span id='7Doi2'><b id='7Doi2'><form id='7Doi2'><ins id='7Doi2'></ins><ul id='7Doi2'></ul><sub id='7Doi2'></sub></form><legend id='7Doi2'></legend><bdo id='7Doi2'><pre id='7Doi2'><center id='7Doi2'></center></pre></bdo></b><th id='7Doi2'></th></span></q></dt></tr></i><div id='7Doi2'><tfoot id='7Doi2'></tfoot><dl id='7Doi2'><fieldset id='7Doi2'></fieldset></dl></div>

                            <small id='7Doi2'></small><noframes id='7Doi2'>

                            <legend id='7Doi2'><style id='7Doi2'><dir id='7Doi2'><q id='7Doi2'></q></dir></style></legend>