Tag Archives: php

Uncaught type error: cannot read property ‘MSIE’ of undefined

Error:
uncaught typeerror: cannot read property ‘MSIE’ of undefined
reason:
$. Browser method has been removed in jQuery 1.9
write a $. Browser code by yourself (recommended)
write it in the script after jQuery reference

jQuery.browser = {};
(function () {
    jQuery.browser.msie = false;
    jQuery.browser.version = 0;
    if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
        jQuery.browser.msie = true;
        jQuery.browser.version = RegExp.$1;
    }
})();

PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[08004] [1040] Too many connections

preface

The OJ, which was built before, suddenly made an HTTP 500 error this evening. When I opened the log, I found that the MySQL database collapsed.

Text

Then open the MySQL configuration file. The path of the configuration file is as follows

/etc/mysql/mysql.conf.d/mysqld.cnf

Max the number of links in it_ Change the connections to 1000, and then restart mysql.

404 solution for WordPress Chinese tag

One of the common problems in blogs or websites built by WordPress is that the Chinese tag link does not exist. Google Administrator Tool prompt grabs 404 errors. In particular, windows hosts often have Chinese tag link grabbing errors, and Chinese tags cannot be displayed normally. Or Chinese tags can be displayed normally, but 404 errors will appear after clicking the link, which brings great inconvenience to users and is extremely difficult It greatly reduces the friendliness of the website.

How to solve this problem?

First method:

Open WP include/ classes.php (before 3.1) or WP include/class- wp.php (after 3.1 +, hereinafter referred to as the new version) find line 154 (the new version is line 142)

$pathinfo = $_ SERVER['PATH_ INFO';

Replace with:

$pathinfo = mb_ convert_ encoding($_ SERVER['PATH_ INFO'], 'UTF-8', 'GBK');

Find line 159 (the new version is line 147)

$req_ uri = $_ SERVER['REQUEST_ URI'];

Replace with:

$req_ uri = mb_ convert_ encoding($_ SERVER['REQUEST_ URI'], 'UTF-8', 'GBK');

After my personal test, this method can be used, the new version of the statement may be different from the above, but the method is basically the same, the corresponding statement can be replaced.

Second method:

1. Found in the WP includes folder at the root of the site“ rewrite.php ”This document;

2. Back it up“ rewrite.php ”In case of error (we’d better back up the original code before changing the code);

3. Open“ rewrite.php ”We find the following code in the file:

function get_tag_permastruct()
{
   if (isset($this->tag_structure)) 
  {
    return $this->tag_structure;
  }
  if (empty($this->permalink_structure)) 
  { 
    //Change this line
    $this->tag_structure = '';
    return false;
  }
  if (empty($this->tag_base))
  $this->tag_structure = $this->front . 'tag/';
  else$this->tag_structure = $this->tag_base . '/';
  $this->tag_structure .= '%tag%';
  return $this->tag_structure;
}

4. Put some of them together

" if (empty($this->permalink_structure)) { ”

Amend to read

“ if (! empty($this->permalink_structure)) { ";

Note that there is only a “!” sign in English. After testing, this method is very effective. PS. didn’t find the code in this file directly…

The third method: the final solution to the Chinese tag 404 error is actually ISAPI_ Rewrite pseudo static rules are not well written, which leads to the failure to find the web page file. In fact, just change the rules: the previous tag pseudo static rules

RewriteRule /tag/(.*)$ /index\.php\?tag=$1

Changed rules

RewriteRule /tag/(.*)/$ /index\.php\?tag=$1

I didn’t test this method, so I can’t guarantee its availability. Please back it up before modification!

Third method:

If the above two methods are not feasible, we recommend another method: alias each tag.

Alias is another URL friendly name. It is usually lowercase and can only contain letters, numbers and hyphens.

But for blogs with more than 100 Chinese tags, this method has a huge workload. Use with caution.

This method can link English tags normally, but it works for websites with Chinese tag problems, but it doesn’t work for websites with 404 English tag links.

How to Solve SQL state [HY000]: general error 2503

SQLSTATE[HY000]: General error 2503

This error is caused by $this – & gt; query. In version 3.2.3, the query and execute methods should be called separately, otherwise an error will be reported in debug mode

After 3.2.3, the TP framework requires different method calls for read and write operations. If it is used incorrectly, an error will be reported in non debugging mode.

Read data using $this->query
Write data using $this->execute

After TP5, it is written as follows:

Read data using Db::query
Write data using Db::execute

Phpstrom reported an error when using SVN: CreateProcess error = 2, the system could not find a solution for the specified file

After phpstrom is installed, the following error will appear during SVN checkout:

Cannot load supported formats: Cannot run program “svn”: CreateProcess error=2

The reason is that SVN uses command-line tools. If there is no SVN command-line tool locally, it will lead to an error.

Solution

Re install SVN, select the installation command line and complete the installation

Change to:

Then all the way to next, the installation is successful.

Restart phpstrom, SVN can be used normally.

PHP in Windows combined with bat batch processing to achieve multi process verification proxy server function

PHP in Windows combined with bat batch processing to achieve verification proxy IP server function

1、 Capture and verify proxy through curl of PHP

Second, multi process processing through bat

Third, merge the results of multi process processing

PHP in Windows combined with bat batch processing to achieve verification proxy IP server function

   due to business, proxy server is needed. There are many sites providing proxy server information on the Internet, so you can get information from these sites. However, due to the network or other reasons, some of the obtained IP is inaccessible, so we need to do verification filtering to get the proxy server that can be used.

1、 Capture and verify proxy through curl of PHP

   grab with curl

thinking

   1. Curl grabs website content;
   2. Simple_ html_ DOM (click to download) parses the captured content, parses the key information, and saves the file (or cache);
  3. Perform curl verification on the key information (IP and port of proxy server);
  4. Verification is divided into HTTPS and HTTP methods, which should be distinguished.

2、 Multi process processing by bat

thinking

   1. A single CMD window can run a php.exe Process, multiple processes can run multiple processes;
   2. Modify the PHP program, support the parameter transfer of CLI mode, different website links can be captured through different parameters;
   3. Run multiple CMDS through the start command (view the description), and use & amp; Connect, make main.bat File;
   4 main.bat The running status of other CMD windows can be monitored in the file, which can be obtained in the tasklist by setting the title of the CMD;
   5. After the running of other CMD windows (PHP tasks) is completed, the result set is merged.

3、 Merging the results of multiprocessing

   take out the file saved in the first step, and then merge the result with PHP code, and output it to result_ xxx.json It can be done in the middle;

The code will not be posted for the time being. It will be updated later.


New version of grafana add data source error!

Premise:

There are no errors in the data source URL configured by grafana.

 

Phenomenon:

1) After upgrading grafana, it is found that the original configured open face data source is invalid, and HTTP error not found is always prompted.

2) After installing the new version of grafana, we found that ZABBIX data source configuration always reported an error, could not connect to given URL.

 

handle:

1) Re install the version under grafana 5.4.

2) Check the configuration of ZABBIX user name and password.

 

The specific reasons and how to configure them above grafana 5.4 have not been studied yet.

Reproduced in: https://www.cnblogs.com/whych/p/10793709.html

Failed to open stream: http request failed!

 

When using PHP5’s own file_ get_ Content method to get remote files (in my

There are similar call requirements in the automated test framework, and sometimes the file will appear_ get_ Contents(): failed to open stream: http request failed.

 

The solution is to modify php.ini Let_ url_ Fopen is enabled and changed to allow_ url_ fopen = On

 

This can solve some people’s problems. Some people say that in China php.ini In, there are two options: allow_ url_ Fopen = on (indicates that the remote file can be opened through URL), user_ Agent = “PHP” (which script is used to access the network. By default, there is a “;” in front of it.) Restart the server.

But some will still have this warning message. If you want to use the perfect solution, you still need to set it php.ini User in it_ Agent, PHP’s default user_ Agent is PHP. We can change it to Mozilla/4.0 (compatible; MSIE 6.0; windows NT 5.0) to simulate browser, user_ agent=”Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)”