Tag Archives: php

php mysqli_ connect_ Error () and mysqli_ connect_ The difference of errno() function

First let’s look at the official definition:

Grammatical definitions:
Definition:
> Mysqli_connect_error () : The function returns an error description of the last connection error.
> Mysqli_connect_errno () : The function returns the error code for the last connection error.

Note: One returns an error description and the other an error code.

Error prompt of MAPP opening PHP under Mac OS

1. First step: modify the php.ini file: Open/Applications/MAMP/bin/PHP/{your PHP version}/conf/PHP ini file
find display_errors = Off (about 277 lines of location), to establish display_errors = On and find the error_reporting = E_ALL (about 270 lines of position, there are three kinds of value type, According to their own needs to set)

2. The second step is to set the Log errors option of mamp pro:
Main window-& gt; php-> Log errors selects to_screen so that the error prompts

on the browser to restart the service.

GuzzleHttp cURL error 60: SSL certificate problem: self signed certificate

An error problem
When GuzzleHttp makes an HTTPS request, it reports the following error

cURL error 60: SSL certificate problem: self signed certificate

The solution
The difference between an HTTP request and an HTTPS request is that Guzzle needs to pass in a configuration item in the constructor,

$client = new \GuzzleHttp\Client(['verify' =>false]);

Mailer Error: SMTP Error: data not accepted.

Mailer Error: SMTP Error: Data not Accepted.
Possible reasons:
Your server does not allow different senders and user names
Some servers require that the sender E-mail address be the same as the E-mail address used for authentication. Check your name and match it with the user name you used to log in to the SMTP server.
The file size of the mail is large
If the body is too large, some servers will reject the message. HTML e-mails are usually larger than plain text messages, but you should try to reduce the size by removing some content or disabling embedded images.
The receiver is blacklisted or blocked
Sometimes certain E-mail addresses are blocked, and the server will reject your messages in order to prevent being blacklisted. The best solution is to choose different delivery methods.
This is a temporary problem
Sometimes, the E-mail server will respond to this error if certain limits are reached or if the send is “too fast.” Please pause your AD campaign for a while and try again later.
If you send through Amazon SES, you must verify the origin, reply, and return addresses you use in your mail.

Laravel 500 server error, perfect solution

After installing the Laravel project, open the Laravel for the first time

Solutions:
1. Open the configuration file laravel/config/app.php

3. Find ‘debug’ set to true

4. Run exception: No Application Encryption key has been specified.

5. Find.env. Example under Laravel, make a copy and rename it as “.env”

6. Execute the command: PHP Artisan Key: Generate under Laravel, then refresh the page
 

Perfect solution!

Parse error: syntax error, unexpected end of file in XXXXXXXX

Something similar appears in PHP programs
Parse error: syntax error, unexpected end of file in XXXXXXXX on line xx
The error.
If you find nothing wrong with the SYNTAX of PHP itself. Short tags may be used, such as:
< ?}?>
The solution to this problem is:
You can set short_open_tag = On
in php.ini

———————————————————
What is short_open_TAG?

determines whether the abbreviated form of the code start flag is allowed (< ??> ). If you want to use PHP in conjunction with XML, you can disable this option to embed < ?xml ?> . Otherwise you can output it through PHP, for example: < ?php echo ‘< ?The XML version = “1.0” ‘; ?> . If disabled, you must use the full form of the PHP code start flag (< ?php ?> ).

note: this instruction also affects the abbreviation < ?=, and < ?Echo equivalence. Using this abbreviation requires that the value of short_open_TAG be On.

PHP CI (CodeIgniter) log level setting

1, Ci error level setting is generally in index. PHP, you can set the ENVIRONMENT. Generally speaking, development mode is selected when developing, and production mode is selected after the official release. The code is as follows:

/*
 *---------------------------------------------------------------
 * APPLICATION ENVIRONMENT
 *---------------------------------------------------------------
 *
 * You can load different configurations depending on your
 * current environment. Setting the environment also influences
 * things like logging and error reporting.
 *
 * This can be set to anything, but default usage is:
 *
 *     development
 *     testing
 *     production
 *
 * NOTE: If you change these, also change the error_reporting() code below
 *
 */
	define('ENVIRONMENT', 'development');
/*
 *---------------------------------------------------------------
 * ERROR REPORTING
 *---------------------------------------------------------------
 *
 * Different environments will require different levels of error reporting.
 * By default development will show errors but testing and live will hide them.
 */

if (defined('ENVIRONMENT'))
{
	switch (ENVIRONMENT)
	{
		case 'development':
			error_reporting(E_ALL);
		break;
	
		case 'testing':
		case 'production':
			error_reporting(0);
		break;

		default:
			exit('The application environment is not set correctly.');
	}
}

2, CI error log by default in the application/logs/log – [time]. PHP, log level, path, time format, etc., in the application/config/config. The PHP file Settings, the code is as follows:

/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
|	0 = Disables logging, Error logging TURNED OFF
|	1 = Error Messages (including PHP errors)
|	2 = Debug Messages
|	3 = Informational Messages
|	4 = All Messages
|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 0;

/*
|--------------------------------------------------------------------------
| Error Logging Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| application/logs/ folder. Use a full server path with trailing slash.
|
*/
$config['log_path'] = '';

/*
|--------------------------------------------------------------------------
| Date Format for Logs
|--------------------------------------------------------------------------
|
| Each item that is logged has an associated date. You can use PHP date
| codes to set your own date formatting
|
*/
$config['log_date_format'] = 'Y-m-d H:i:s';

3, in their own code to log, you can call the global function log_message(‘ level ‘,’ message ‘), the level of parameters is (debug Debug, error error, information info), the content can be defined by themselves.

log_message('error', 'error message.');
log_message('debug', 'debug message.'); 
log_message('info', 'info message.');  

PHP uses timthumb to generate thumbnails

Recently, I need an interface for online screenshots, but I haven’t found it suitable for a long time, and then It is a little troublesome to write it by myself. Suddenly, I remember that I encountered a slightly thumbnail class when I was using wordpress. Don’t use it too easily. I recommend it here.
Anyone who has used the Timthumb class should be familiar with it. This class can be used to generate and process thumbnails of images, or to take screenshots of websites if you have optipng or pngCrush installed in a Linux environment.
File download address: http://www.121xz.com/softdown/19577
Wordpress comes every time to upload the features of the thumbnails of all images by cutting according to set the image size, and cut the original image and the image stored in the web space, image cut only once, change the Settings of the size will not regenerate, so not only occupy the host space, after revision sites use the same images, even when otherwise image distortion or deformation. Timthumb. PHP is a thumbnail application project integrated in wordpress theme specially developed for wordpress. It will only crop the called images, and only generate a configuration file temporarily when there is an access request.
Parameter description:
SRC: the need for image zooming source address, or the need for screenshots operation web address webshot: if this value is true, for screenshots operation w: generate the width of the image, if the width or height only set up a value, according to one of the values for geometric scaling of h: the height of the generated images, if the height and width is not specified, the default is 100 * 100 zc: generate picture zoom mode, optional value of 0, 1, 2, 3, the default is 1, the difference between each value annotation line 100 q can see the following documents: Generated images quality, the default 90 a: beyond the cutting location of parts, and zooming pattern, optional value t, b, l, r, the default is cut from the top to f: need to generate images after use some filters, here are the different code and the value of the filter, the specific operation method is the line 821 annotations file below s: whether to sharpen the production pictures of cc: generating background canvas picture color ct: generate PNG image background is transparent
Warm tips:
Timthumb requires host support for GD libraries; The processing of Timthumb requires certain server resources. Timthumb does not support external linked images; There have been holes in Timthumb; The author indicates that Timthumb is no longer updated.
Patch the bugs in Timthumb. PHP:
Whitelists are removed using the latest version of timthumb. PHP (but the author says no more updates) server directory permissions Settings
Find the following code in the file, delete or comment it out

1
2
3
4
5
6
7
8
// external domains that are allowed to be displayed on your website
$allowedSites = array (
        'flickr.com',
        'picasa.com',
        'blogger.com',
        'wordpress.com',
        'img.youtube.com',
);

Syntax error: unexpected end of file problem [two solutions]

The article directories
Modify the php.ini configuration file to use notepad++ conversion format


PHP upload files to the server can be said to have a bumpy journey, there is a problem… About syntax error: Unexpected end of File, this problem is usually not your code problem. If you are using Linux server, after editing the script in Windows environment, the file format will be wrong because of incorrect return characters.
Modify the php.ini configuration file
This method is used to solve the problem, generally speaking. ?php?> That’s the normal way of writing it, but < ??> This can also be used as a short label. If you have PHP in this format, go to php.ini, modify short_open_tag = Off, change “Off” to “On”, and restart Apache.
Use notepad++ to convert the format
The reason for this is that the format layout under Linux is different from that of Windows, so I need to convert the file into
in Linux/ Unix format. At present, I haven’t found a way to convert the file into
in Linux/ Unix format. If you know, please inform ~

call to member function bind_param() on boolean………..

Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in …. Stack trace: #0 {main} thrown in……… This error is usually caused by the wrong database table name, resulting in the previous parameter could not get the correct value, you can check the parameter value correctly by typing var_dump(param_name)

Reproduced in: https://blog.51cto.com/haiyanyuan/1731256