Tag Archives: php

A method of collecting JS dynamic content by PHP

1、 Download and install phantomjs according to your own platform https://phantomjs.org/download.html

2、 Call a JS file to access the URL connection that needs to be collected

// Example using HTTP POST operation

"use strict";
var page = require('webpage').create(),
    system = require('system'),
    server = system.args[1],
    settings = {
    encoding: "utf8",
    headers: {
        "Content-Type": "text/html",
        "Cookie": "cookie",
        "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"

page.open(server, settings, function (status) {
    var content = page.evaluate(function() {
       return document.getElementById('uiContent').innerHTML;


$url = $_REQUEST['url'];
$command = "phantomjs cread.js " . $url;
echo $content[0];


Array of PHP_ diff,array_ intersect,array_ merge, in_ Is there a limit on the number of arrays in array?

1. First of all, I build a table of 10W data.

2. Use the method in TP to take out the column for array_ diff,array_ intersect,array_ Merge can calculate the normal output, and the response is millisecond.

(the figure below is the result of normal calculation)

(the following figure shows the response in seconds. Of course, you can also measure the time-consuming of this code. If I have less time, I will not measure it.)

E: unable to locate package MySQL server error solution

In Ubuntu system, using the apt-get install command to install the program, the following problems occurred.

[email protected]:~# sudo apt-get install mysql-server -y
sudo: unable to resolve host iZm5ej8y1b74lo14r36fvlZ
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package mysql-server

Sudo apt-get update sudo apt-get update
The software source is not updated, or the software source is modified,

sudo apt-get update

Second method: need to change the software source
Refer to the method of replacing the software source:


E: Unable to locate package mysql-server: Unable to locate package mysql-server: Unable to locate package mysql-server

How to Hide index.php



server {
        listen        80;
        server_name  www.mxscs.com;
        root   "D:/develop_soft/daima_mxs/ib_crm_bonus";
           if (!-e $request_filename) {  
                rewrite ^/(.*)$ /index.php/$1 last;
            index index.php index.html error/index.html;
            error_page 400 /error/400.html;
            error_page 403 /error/403.html;
            error_page 404 /error/404.html;
            error_page 500 /error/500.html;
            error_page 501 /error/501.html;
            error_page 502 /error/502.html;
            error_page 503 /error/503.html;
            error_page 504 /error/504.html;
            error_page 505 /error/505.html;
            error_page 506 /error/506.html;
            error_page 507 /error/507.html;
            error_page 509 /error/509.html;
            error_page 510 /error/510.html;
            include D:/develop_soft/daima_mxs/ib_crm_bonus/nginx.htaccess;
            autoindex  off;
        location ~ \.php(.*)$ {
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;


A convenient method to count the total number of query results in MySQL

MYSQL keywords:
to check the manual and found this keyword is used in the query result of statistical filtering conditions when the total number of (not restricted by Limit)
For example:

SELECT SQL_CALC_FOUND_ROWS tid FROM cdb_threads WHERE fid=14 LIMIT 1,10;

Let’s say there are 1,000 that satisfy our condition, and we return 10.

for immediate use

SELECT found_rows() AS rowcount;

Return rowcount = 1000;
this saved a SELECT count (*) AS the rowcount repeat query, can save considerable time.

From: http://ginew.blog.163.com/

Wechat third party authorization to generate QR code API

$api = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=xxx&pre_auth_code=xxx&redirect_uri=xxx&auth_type=xxx";

is not allowed to directly access the API generated above, it must be the source URL, and the source URL must be the same as the one set in the third party platform.

Call to undefined function mysql_ Connect() solution summary

Use the phpinfo() function in your PHP code to see PHP basics
Mysql_connect () has been deprecated since PHP5.0, and is deprecated in PHP7.0. Mysqli_connect () is used instead if PHP is 7.0 or higher
Method 2:
Missing MySQL module caused by PHP installation
Mysql> install mysql from CentOs
yum install php-mysql -y
If installed, report the following warning
Headers and client library minor version mismatch. Headers:
This is due to the higher version of MySQL, the lower version of the MySQL Client API
You can uninstall php-mysql first
yum remove php-mysql -y
yum install php-mysqlnd -y
Finally, restart Apache
systemctl restart httpd
Ubuntu install MySQL module:
Apt to get the install php5 – mysql
Sudo DPKG — reconfigure php5 – mysql
sudo /etc/init.d/mysql restart
sudo /etc/init.d/apache2 restart
If the first two methods fail, try opening the MySQL module extension in the php.ini configuration file
Php.ini = php.ini; Extension =” related MySQL module “; To get rid of
Then make sure that the dir of extension points to the directory where the extension resides
Windows is usually under Ext and CentOS is under /usr/lib64/php.modules
The above information can be found in the PHPINFO printed information
However, when I encountered this problem, I just needed to install the PHP-MySQL module, and I didn’t need to modify php.ini
My environment is Centos7 and PHP version is PHP5.4

Fatal error: Uncaught Error: Call to undefined function mysql_ Connect() problem solving

Fatal error: Uncaught error: Call to undefined function mysql_connect() : Fatal error: Uncaught error: Call to undefined function mysql_connect() when connecting to the database using PHP validation code. This is because the version of PHP you are using does not support the older version of join statement writing. The PHP version used in this study is PHP-7.4.2-NTS-Win32-VC15-x64, and the verification code is:
< ?PHP
the mysql_connect (‘ ‘, ‘runner_db_user’, ‘runner_db_password’)
the OR die (” Could not connect to the database. ‘);
the mysql_select_db (‘ hfjq_race_info ‘);
echo “Connected!” ;
After inquiry, this writing method is the previous version of 5. X, the following code is as follows:
< ?php
$con=mysqli_connect(“”, “runner_db_user”, “hfjq_race_info”)
OR die(‘Could not connect to database.’);
echo “Connected!” ;
You can connect to the database normally. If you have extension=mysqli, change the semicolon “;” before extension=mysqli. You can connect to the MySQL database normally if you remove it

Uncaught error: call to undefined function MySQL when building sqli lab environment with phpstudy_ Connect() error

The problem

Uncaught Error: Call to undefined function mysql_connect()

In PHP 5+, you can use both mysql_connect() and mysqli_conncet() instead of mysqli_conncet().
The solution
In the PHPStudy environment, you can downgrade the PHP version by selecting the PHP5 + version.

Web site – & gt; Management – & gt; PHP version. (You can choose to replace an older version of PHPStudy.)
If you want to use php7 without changing the code, you can use the admin ->; For PHP extensions, check the box before php_mysql.

In thinkphp5, we encountered the problem of class’ phpoffice / phpspredsheet / spreadsheet ‘not found

When you’re using Excel import and export and you’re using PHPSpreadsheet you’re going to use Composer,

 composer require phpoffice/phpspreadsheet

In fact, when you compose your PHPSpreadsheet, you should never move it. This will cause problems with your paths and everything
Composer down you don’t move and don’t copy the file, can appear otherwise Class ‘PhpOffice \ PhpSpreadsheet \ Spreadsheet’ not found this problem

Anything circled in red should not be moved or copied

Class ‘PHPWord_Writer_Word2003‘ not found

Error in using PHPword to generate word:
Fatal error: Uncaught error: Class ‘PHPWord_Writer_Word2003’ not found in D:\ phpStudy_Pro \WWW\newword\ phpWord \ phpWord \ iofactory.php :110 Stack trace: #0 D:\ phpStudy_Pro \WWW\newword\ DEMO (132): PHPWord_IOFactory::createWriter(Object(PHPWord), ‘Word2003’) #1 {main} Thrown in D:\ phpStudy_Pro \WWW\newword\ PHPWord\ PHPWord\ PHPWord\ iofactory.php on line 110

The word version that should be used with you is concerned, I change Word2003 here 2007 can be used normally!

— — the END — —