Tag Archives: php

Using the TP framework, an error is reported sqlstate [08004] [1040] too many connections

Use
when MySQL inserts a large amount of data and needs to compare and duplicate          Db($table)-> where($where)-> find();

In this case, an error will be reported: sqlstate [08004] [1040] too many connections

This is mainly due to too many database connections

resolvent:

        Introduce DB class

                 use think\Db;

        The query statement is changed to:

                 Db::table($table)-> where($where)-> find();

That’s it

[Solved] Error during composer operation in docker: insufficient memory

Background
Need to perform composer removal package operation on lumen framework.
Error message

docker composer remove Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 byt

Solution:

/usr/local/bin/php -d memory_limit=-1 /usr/local/sbin/composer remove xxx

Explanation: php -d memory_limit=-1 means that the php process uses unlimited memory.
Note that both php and composer need to use absolute paths.

Error during session start; please check your PHP and/or webserver log file and configure your PHP

Environment: Windows Server 2008 R2 IIS7.5 PHP7.3+
Error:
Error during session start; please check your PHP and/or webserver log file and configure your PHP installation properly. Also ensure that cookies are enabled in your browser.
Solution:
Permissions problem, Windows – temp set IIS_IUSRS write permissions, solved.

[Solved] PHP Fatal error: Uncaught Error: Class ‘Redis‘ not found in

The problem is that the redis class cannot be captured in the message

However, I have installed redis and used it in PHP code, but when I execute PHP jifen.php in Linux system, I report that redis class cannot be found.

Solution:

First, determine if there are two PHP in your system.

find/-name php

Then find your current PHP Directory:

Use phpinfo () in the PHP file; Method, you can access it

My PHP files are at /www/server/PHP/73/

Modify the system environment file:/etc/profile

vi /etc/profile

Write the PHP environment address to the end of the configuration file


The PHP runtime files are inside the bin directory, so mine is: /www/server/php/73/bin/

export PATH=$PATH:your PHP address

Save, exit, and then run:

source /etc/profile

Restart the PHP file to use PHP jifen.php

 

[Solved] Type error: Argument 1 passed to Monolog\Utils::getClass() must be an instance of Monolog\object

Type error: Argument 1 passed to Monolog\Utils::getClass() must be an instance of Monolog\object


Error reason.
Because the PHP version is too high, 2.x minimum requirement PHP7.2 The official original words are as follows:

https://github.com/Seldaek/monolog
Requirements
Monolog ^2.0 works with PHP 7.2 or above, use Monolog ^1.25 for PHP 5.3+ support.

Solution:
composer downgrade monolog/monolog version

"require": {
    "monolog/monolog": "^1.25",
}

TP5 fuzzy Chinese characters error [How to Solve]

When using TP5 to fuzzy query Chinese characters, sometimes some Chinese characters will report errors, which are placeholder errors, so modify the paging style;

Modify the bootrapthink.php file

return sprintf(
//                    '<div id="page" class="page_div pagination">%s %s %s<span class=\'totalSize\'> 跳转<input class=\'jump_class jump_page_num\' οnkeyup="this.value=this.value.replace(/\D/, \'\');" type=\'text\' value=\'\'>页 </span><a href=\'javascript:void(0);\' οnclick=\'jumpPage(this);\' data-href="'.$base_url.'" class=\'jump_btn\' style=\'color: #18a689;border: 1px solid #18a689!important;margin-left:0px;\'>确定</a><span class="totalPages"> 共<span>'.$this->lastPage.'</span>页 </span><span class="totalSize"> 共<span>'.$this->total.'</span>条记录 </span></div>',
//                    $this->getPreviousButton(),
//                    $this->getLinks(),
//                    $this->getNextButton()

Sometimes you will find something wrong with his placeholder

Change to:

return '<div id="page" class="page_div pagination">'.$this->getPreviousButton().' '.$this->getLinks().' '.$this->getNextButton().'<span class=\'totalSize\'> 跳转<input class=\'jump_class jump_page_num\' οnkeyup="this.value=this.value.replace(/\D/, \'\');" type=\'text\' value=\'\'>页 </span><a href=\'javascript:void(0);\' οnclick=\'jumpPage(this);\' data-href="'.$base_url.'" class=\'jump_btn\' style=\'color: #18a689;border: 1px solid #18a689!important;margin-left:0px;\'>确定</a><span class="totalPages"> 共<span>'.$this->lastPage.'</span>页 </span><span class="totalSize"> 共<span>'.$this->total.'</span>条记录 </span></div>';

With specific analysis of the situation, finally, I wish you all a smooth work!

[Solved] WordPress Upgrade PHP 5.6 to 7.x Fatal error: Uncaught Error: Call to undefined function mysql_connect()

Error reporting when upgrading PHP version 5.6 to 7. X under WordPress (resolved)

Cause of event:

When using WordPress, the theme needs to be upgraded. The PHP version required for viewing the theme is 7.1+

When the website is not backed up, the PHP version is changed to 7.2, which directly leads to the website error

Fatal error: Uncaught Error: Call to undefined function mysql_ connect()

Check many online tutorials, which are MySQL in wp-db.php_Change connect() to mysqli_Connect(), no result

At first, I thought that the database reported an error, checked the database in detail, wrote checkdb.php, locally connected to the database, and checked that the database server was running well

Solution:

Set define ('wp_use_ext_mysql ', true) in wp-config.php delete

error explanation:

define('WP_USE_EXT_MYSQL',true);

define(‘WP_USE_EXT_MYSQL’, true); Force WP to use MySQL by default instead of MySQL Li
so please delete this line and the problem should be solved.

Otherwise, you can check nd in the PHP 7 configuration_Mysqli extension, and disable mysqli extension – > Select the PHP version.

Error while injecting dependencies into App\Controller\IndexController: No entry or class found for

An error occurs when a service consumer class is manually created for the hyperf 2.2.0 microservice.

In the documentation on the official website, when manually creating a consumer class, its recommended configuration of services.php is as follows.

<?php
return [
    'consumers' => [
        [
            'name' => 'CalculatorService',
            'registry' => [
                'protocol' => 'consul',
                'address' => 'http://127.0.0.1:8500',
            ],
            'nodes' => [
                ['host' => '127.0.0.1', 'port' => 9504],
            ],
        ]
    ],
];

Later, I saw the video on the official website jsonrpc. The recommendation in the video is as follows.

<?php
return [
    'consumers' => [
        [
            'name' => 'CalculatorService',
            'nodes' => [
                ['host' => '127.0.0.1', 'port' => 9504],
            ],
        ]
    ],
];

I wonder if the above writing is only applicable to the 1. X.x era?When I upgrade to 2.2.0, it is reported above

[ERROR] Error while injecting dependencies into App\Controller\IndexController: No entry or class found for ‘App\Rpc\CalculatorServiceInterface'[101]

After tossing for a long time, I found that there are few services.php configurations

    'service' => \App\Rpc\CalculatorServiceInterface::class,

So, don’t lose service. The complete services.php is like this

return [
    'consumers' => [
        [
            // name needs to be the same as the name attribute of the service provider
            'name' => 'CalculatorService',
            // service interface name, optional, default value is equal to the value configured by name, if name is defined directly as an interface class then this line can be ignored, if name is a string then you need to configure service to correspond to the interface class
            'service' => \App\Rpc\CalculatorServiceInterface::class,
            // corresponding to the container object ID, optional, default value is equal to the service configuration value, used to define the dependency injection key
            'id' => \App\Rpc\CalculatorServiceInterface::class,
            // Service protocol of the service provider, optional, default value is jsonrpc-http
            // optional jsonrpc-http jsonrpc jsonrpc-tcp-length-check
            'protocol' => 'jsonrpc-http',
            // load balancing algorithm, optional, default value is random
// 'load_balancer' => 'random',
            // which service center this consumer will get the node information from, if not configured it will not get the node information from the service center
// 'registry' => [
// 'protocol' => 'consul',
// 'address' => 'http://127.0.0.1:8500',
// ],
            // If the above registry configuration is not specified, i.e., the node is consumed directly for the specified node, and the node information of the service provider is configured with the following nodes parameter
            'nodes' => [
                ['host' => '127.0.0.1', 'port' => 9504],
            ],
        ]
    ],
];

Run later and run through

[Solved] Fatal error: Class ‘think\Container‘ not found & [InvalidArgumentException] Could not find package

Fatal error: class’ think \ container ‘not found. This error means that the ThinkPHP core framework warehouse is not a branch of version 5.1, so the container of version 5.1 is not found;

The solution is to execute the following command on the terminal terminal of the IDE:

composer create-project topthink/think tp 5.1.35

Starting from tp5.1, the official website no longer provides a full version download, but can only be installed through the composer method.

[invalidargumentexception] could not find package. This error means that the installation package of the corresponding version is not found. The problem in the figure below is that the version number behind 5.1 is missing. It is correct after supplement as shown in the figure above.

  The program operation after correct input is as follows:

[Solved] getObject: FAILED RequestCoreException: cURL resource: Resource id #78; cURL error: SSL certificate

Reason:

The reason for this problem is that curl.cainfo is not configured, which is located in php.ini.

Solution:

Since the reasons for the errors are stated, it is much easier to solve them, as follows:

1. Download cacert

Download address: https://curl.haxx.se/ca/cacert.pem

2. Modify php.ini and restart

curl.cainfo="real_path/cacert.pem"

matters needing attention:

Needs to be turned on php_curl、php_openSSL extension;

WordPress website map sitemap.xml error repair

WordPress website map sitemap.xml error repair

Error overview

In building a website using WordPress, use the XML Sitemaps plug-in to create a sitemap.xml site map, but after creation, open sitemap.xml and report the following error

Solution

1. Find the wp-blog-header.php file in the root directory of the website and open it. Modify it as follows

<?php
if ( ! isset( $wp_did_header ) ) {
	$wp_did_header = true;ob_start();
	// Load the WordPress library.
	require_once __DIR__ . '/wp-load.php';
	// Set up the WordPress query.
	wp(); ob_end_clean();
	// Load the theme template.
	require_once ABSPATH . WPINC . '/template-loader.php';
}

2. Refresh sitemap.xml to find that it can be used