Category Archives: PHP

Thinkphp6 Error: constraint violation: 1052 Column ‘id’ in where clause is ambiguous

Cause

Show a column model

<?php
declare (strict_types=1);

namespace app\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class Column extends Model
{

    public function articles()
    {

        return $this->belongsToMany(Article::class, 'column_article', 'article_id', 'column_id');
    }


    public function hasArt($article_id)
    {
        return $this->articles()->where('id', $article_id)->count();
    }

}

Wrong package when using

constraint violation: 1052 Column 'id' in where clause is ambiguous...

The reason for the error is that the relationship model of ThinkPHP does not know which table ID it is,

Here, we need to know which table it belongs to when sorting, so we also need to specify the table name when using it (Note: it needs to be prefixed)

    public function hasArt($article_id)
    {
        return $this->articles()->where('lu_article.id', $article_id)->count();
    }

[Solved] PHP Hprose Client Error: ‘Tag ‘RAEz’ expected

When the client requests the server, an error appears: (tag ‘raez’ expected, but ‘this error can be seen

1. Is the comment on the always_populate_raw_post_data configuration in php.ini opened?If not, you can!

2. If you continue to report the error according to the above modification, it is sufficient to check the user’s permission to the project. After the landlord modifies the Chmod – R 777 project name with the command, the project can be accessed normally.

PHP5.6.27 Install error: error: dereferencing pointer to incomplete type ‘EVP_PKEY’ {aka ‘struct evp_pkey_st’}

Php5.6.27 make && Make install reports an error and cannot be resolved. The error contents are as follows:

/usr/develop/php-5.6.27/ext/openssl/openssl.c:3485:14: error: dereferencing pointer to incomplete type 'EVP_PKEY' {aka 'struct evp_pkey_st'}
  switch (pkey->type) {
              ^~
/usr/develop/php-5.6.27/ext/openssl/openssl.c: In function 'php_openssl_pkey_init_dsa':
/usr/develop/php-5.6.27/ext/openssl/openssl.c:3557:10: error: dereferencing pointer to incomplete type 'DSA' {aka 'struct dsa_st'}
  if (!dsa->p || !dsa->q || !dsa->g) {
          ^~
/usr/develop/php-5.6.27/ext/openssl/openssl.c: In function 'php_openssl_pkey_init_dh':
/usr/develop/php-5.6.27/ext/openssl/openssl.c:3580:9: error: dereferencing pointer to incomplete type 'DH' {aka 'struct dh_st'}

Reason: php5.6.27 and OpenSSL 1.1.1c are incompatible.

I checked my OpenSSL version:

[[email protected] php-5.6.27]# openssl version
OpenSSL 1.1.1c FIPS  28 May 2019

Preliminary solution: downgrade the version of OpenSSL. I chose openssl-1.0.0c. Recompile the installation and there will be no compilation errors.

yum remove -y openssl
cd /usr/apps/
wget -c ftp://ftp.openssl.org/source/openssl-1.0.0c.tar.gz
tar -zxf openssl-1.0.0c.tar.gz
cd openssl-1.0.0c/
./config  --prefix=/usr/local --openssldir=/usr/local/ssl
make && make install
./config shared --prefix=/usr/local --openssldir=/usr/local/ssl
make clean 
make && make install
openssl version # check the version

It’s useless to find. There are always all kinds of problems

Final solution: install php7.3.13

[Solved] include(../template/header.html): failed to open stream: No such file or dir…

Introduce the problem of the path. It is recommended to join

include  $_SERVER[‘DOCUMENT_ROOT’].”/template/header.html”;

It means to get include.PHP. In the root of the website

        // Wrong
        // include('../template/header.html');
        // Right
        include $_SERVER['DOCUMENT_ROOT']."/template/header.html";

How to Solve PHP 500 Error

PHP 500 error reporting solution

1. First look at the error log file path specified by nginx error.log, find the log file, look at the information inside
2, and then look at the path of PHP error log specified in php-fpm.conf
as follows

php_flag[display_errors] = off
php_admin_flag[log_errors] = on
php_admin_value[error_log] = /data/logs/fpm-php.log

the in php.ini is invalid. Use PHP FPM to control it

 

[Solved] PHP Error: always_populate_raw_post_data = -1

Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set ‘always_populate_raw_post_data’ to ‘-1’ in php.ini and use the php://input stream instead. in Unknown on line 0

Warning: Cannot modify header information – headers already sent in Unknown on line 0

Solution: Under php.ini file: turn on always_populate_raw_post_data = -1 and then save and restart

Reason: Once enabled, you can receive data with $HTTP_RAW_POST_DATA, but usually we use php://input