Tag Archives: php

Error while sending query packet in PHP runtime

What are the eight life cycle hook functions of Vue>>>

question:

Error while sending query packet in PHP runtime

reason:

1

Run show variables like ‘max in MySQL_ allowed_ packet’;

View Max_ allowed_ Packet value, if Max_ allowed_ If the packet value is too low, the title error will be reported

solution:

Edit my.cnf (my.ini under Windows) and modify it in the [mysqld] section or the server configuration section of MySQL_ allowed_ Packet = 50m (or max_ allowed_ packet = 50 * 1024 * 1024)

command line modify set global Max_ allowed_ packet = 50 * 1024 * 1024

[Solved] PHP Fatal error: Class ‘mysqli’ not found in xxx

Fatal error: class’ mysqli ‘not found in xxx

The error indicates that PHP lacks mysqli extension. You can check the PHP compilation parameters first to confirm/usr/local/PHP5/bin/php-i|grepconfigure

Attached are other common software queries:

nginx:/usr/local/nginx/sbin/nginx-V

apache :cat/usr/local/apache/build/config.nice

mysql:cat/usr/local/mysql/bin/mysqlbug|grepconfigure

It’s true that we didn’t enter the source code package ext/mysqli later

Linux installation is compiled with configuration, but it disappears after we have installed PHP. There is a file called phpize in the command directory bin of PHP5 folder, which can be used to generate configuration

/Usr/local/PHP5/bin/phpize// enter here to run. After execution, the configure file appears

Now add the extension mysqli

./configure –prefix=/usr/local/mysqli –with-php-config=/usr/local/php5/bin/php-config –with-mysqli=/usr/local/mysql/bin/mysql_ config

make && amp; make test && amp; make install

After compilation:

Thank you for helping to make PHP better.
Installing shared extensions: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/
Installing header files: /usr/local/php5/include/php/

The description is normal

Now mysqli. So appears

Modify php.ini file

extension_ Dir = “/ usr/local/PHP5/ext”
extension = mysqli. So new

I found that there are two PHP directories, which may be due to problems in the previous compilation, and both generated php.ini files. I found that they need to be modified to add the last two sentences to run normally

Finally, the generated mysqli.so file CP is put under/usr/local/PHP5/ext

Restart PHP FPM to complete the program

If you feel troublesome, you can directly delete the PHP file of compilation and installation, and the installation directory and configuration file can be recompiled and installed

If you have other questions, you can reply and learn together

Fatal error: class’ mysqli ‘not found in

/login/login_ action.html” method=”post” onSubmit=”return checkform(‘false’)”>

The php.ini file does not recognize the form and needs to be modified

Found

short_ open_ Change tag = on to on

[Solved] PHP write file permission failure: file_put_contents: failed to open stream: Permission denied

Questions

File is used in the method of writing log_ put_ Content this method, when executing the callback method to write the log today, prompts that there is no permission to write to the file, and reports an error

file_put_contents: failed to open stream: Permission denied

Solution process

Check the log folder permissions. Because it is generated on a daily basis, a scheduled task is executed on a regular basis, and the executing user is root. Therefore, both the generating folder user and the user group are root. In the callback method, the executing user is WWW, which is written to the log method

  if(!is_dir($dir)){
        mkdir($dir,0777,true);
    }

If the directory doesn’t exist, create a directory, but set 777 permission to create a folder in PHP’s MKDIR function. In fact, the created file still has 755 permission. In Linux system, there is a default permission when creating files/folders. This permission is affected by umask settings. We can find the following configuration in/etc/bashrc configuration file:

if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
        umask 002
else
        umask 022
fi

The default umask in Linux system is 022, which is similar to our 777 & amp; After the operation, it becomes 755. That’s why. The setting here directly affects the default permission setting of Linux system, not just the problem of PHP. Therefore, it is not recommended to change 022 to 000 directly

Final solution

First create a directory, and then use Chmod to modify the permission to 777

mkdir('test', 0777);
chmod('test', 0777);

What’s the difference between die() and exit() in PHP?

Knowledge map advanced must read: read how large-scale map data efficient storage and retrieval>>>

What is the difference between die() and exit() functions in PHP

I think the two have the same function, but I wonder if there are some differences between the two… What is this


#1st floor

As mentioned earlier, the two commands produce the same parser token

But

One small difference is how long it takes for the parser to return the token

I haven’t studied the PHP parser yet, but if it’s a long string of functions that start with “d” and a short string of functions that start with “e”, it’s going to take some time to find the function name of the function that starts with “.” e “. There may be other differences due to the way the entire function name is checked

I doubt it will be measurable unless you have a “perfect” environment dedicated to parsing PHP and many requests with different parameters. But there must be a difference. After all, PHP is an interpretive language


#2nd floor

There’s no difference – they’re the same

PHP Exit Manual:

Note: this language construction is equivalent to die()

PHP die Manual:

This language construction is equivalent to exit()


#3rd floor

They are essentially the same, although there are other suggestions in this paper


#4th floor

They sound similar, but exit () also allows you to set the exit code for the PHP script

Usually, you don’t actually need this script, but when writing a console PHP script, you may need to check with bash that the script does everything in the right way

You can then use exit () and capture later. Die() is not supported

Die() always exists as code 0. So essentially, the die() command does the following:

<?php
echo "I am going to die";
exit(0);
?>

Same as the following:

<?php
die("I am going to die");
?>

#5th floor

Mold in PHP manual:

Die – equivalent to exit

You can even die and exit same - with or without brackets

The only advantage of choosing die() instead of exit() may be that it saves time typing extra letters; -)

PHP use$_ SERVER[‘PHP_ Self ‘] to get the current page address and its security issues

Knowledge map advanced must read: read how large-scale map data efficient storage and retrieval>>>

PHP $_ SERVER[‘PHP_ SELF’]

$_ SERVER[‘PHP_ Self ‘] indicates the location address of the current PHP file relative to the root directory of the website, which is related to document root

Suppose we have the following website$_ SERVER[‘PHP_ The results of self ‘] are as follows:

http://www.ywp.com/php/ :/php/index.php
http://www.ywp.com/php/index.php :/php/index.php
http://www.ywp.com/php/index.php?test=foo :/php/index.php
http://www.ywp.com/php/index.php/test/foo :/php/index.php/test/foo

Therefore, it can be used$_ SERVER[‘PHP_ Self ‘] it’s very convenient to get the address of the current page:

$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

Taking the above address as an example, the results are as follows:

http://www.ywp.com/php/index.php

The above is a simple way to get the current page URL of the HTTP protocol. Just note that the address does not contain the requested parameter (?) in the URL?And the following string). If you want to get the full URL address that contains the request parameters, use$_ SERVER[‘REQUEST_ URI’] 。

PHP $_ SERVER[‘PHP_ Self ‘] security

Due to the use of$_ SERVER[‘PHP_ Self ‘] can easily obtain the current page address, so some programmers like to use the following method when submitting form data to the current page for processing:

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

Suppose the page address is:

http://www.ywp.com/php/index.php

The HTML code of the form is as follows:

<form method="post" action="/php/index.php">

This code is correct, but when the access address becomes:

http://www.ywp.com/php/index.php/test/foo

The page is executed normally, and the HTML code of the form becomes:

<form method="post" action="/php/index.php/test/foo">

Obviously, this code is not what we expected. Attackers can add attack code at will after the URL. To solve this problem, we can:

Using htmlentities ($_ SERVER[‘PHP_ Self ‘]$_ SERVER[‘PHP_ Self ‘], so that the possible malicious code in the URL can be converted into HTML code for display and cannot be executed

If possible, use$_ SERVER[‘SCRIPT_ [name ‘] or$_ SERVER[‘REQUEST_ Uri ‘] substitution$_ SERVER[‘PHP_ SELF’]

In the common code$_ SERVER[‘PHP_ Self ‘]:

$phpfile = basename(__FILE__);
$_SERVER['PHP_SELF'] = substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], $phpfile)).$phpfile;

File not found error handling of nginx accessing PHP files, two cases

Knowledge map advanced must read: read how large-scale map data efficient storage and retrieval>>>

This error is very common. There are two kinds of errors

PHP FPM could not find script_ PHP file executed in file name

PHP FPM can’t access the executed PHP, which is a permission problem

The first case

Change the configuration file nginx. Conf
fastcgi_ param SCRIPT_ FILENAME /scripts$fastcgi_ script_ name;
replace with the following

fastcgi_ param SCRIPT_ FILENAME$document_ root$fastcgi_ script_ name;

Then reload the nginx configuration file
/etc/init.d/nginx reload

The second situation

Two solutions:
the first is to set your root folder to allow other users
the second is to find your PHP FPM configuration file, find the following paragraph, and replace Apache with the user group you want

; RPM: apache Choosed to be able to access some dir as httpd
user = apache
; RPM: Keep a group allowed to write in log dir.
group = apache

How to Solve PHP Error: Function name must be a string

 

PHP low level error: function name must be a string technology

In my impression, this kind of PHP error is rarely encountered, but once encountered, all of a sudden still can not find the problem

When a person is very tired in the process of development, he makes a low-level mistake. He looks at the screen and doesn’t know why, so the whole network looks for the answer. PHP error: function name must be a string appears in the following code

<?php

$_GET('name');

$_POST('name');

$_COOKIE('name');

?>

Function name and method name must be a string, which is easy to mislead people. PHP 5.3 has started to support anonymous functions, and variables can also be used as functions

 

Cannot load php7apache2 to server

Knowledge map advanced must read: read how large-scale map data efficient storage and retrieval>>>

1. Download php7 http://windows.php.net/download/

2. Configure php7

Change the name of php.ini-production in the PHP installation directory to php.ini

Open php.ini and make the following modifications:

1) Setting the extension path of PHP

Find extension_ Dir = ext, remove the semicolon

2) Open common PHP extensions, such as:

extension=php_ Mbstring.dll (PHP multibyte string extension)

extension=php_ Mysql.dll (MySQL library extension)

extension=php_ Mysql.dll (mysqli library extension)

Opening method: find the above extension, and change the semicolon (;) Just delete it

3) Set default time zone

date.timezone = Asia/Shanghai

3. Configure Apache

Find conf/httpd.conf in your Apache directory and open it to add configuration

4. An error is reported when restarting Apache and it cannot be started

5. To find the error, enter the installation directory apache2.2 in command line, and use httpd – T command

As shown in the figure above, cannot load php7apache2 is displayed_ 4.dll into server

6. It is said on the Internet that 32-bit system uses 32-bit PHP, 64 bit system uses 64 bit PHP, check my 64 bit system and download 64 bit thread php:php-7.0.21-Win32-VC14-x64.zip It has nothing to do with the system and version. It is said that the interface 80 is not turned on. Check that your 80 interface is turned on. It is said that

Download to php7 directory still can’t start

Check VC version, also has vc14. Very helpless, still cannot load php7apache2_ 4.dll into server

Solution:

Just re install Apache 2.4. Apache 2.2 doesn’t support php7. Apache 2.4 installation reference

http://www.cnblogs.com/zhaoqingqing/p/4969675.html

Error 502 when accessing PHP file by phpstorm browser

Knowledge map advanced must read: read how large-scale map data efficient storage and retrieval>>>

Recently, when configuring lamp environment on Ubuntu, editing PHP file on phpstorm and browsing, the browser always prompts 502 bad gateway. Baidu has been unable to find a solution, and finally found it on stackoverflow, as follows:

sudoapt-getinstallphp5-cgi

Depressed, it turned out that I installed this guy less when I installed PHP