Home > Backend Development > PHP Tutorial > How to reduce low-level errors in PHP code and modify the process

How to reduce low-level errors in PHP code and modify the process

WBOY
Release: 2016-08-08 09:32:21
Original
1145 people have browsed it

Note:

1. The mysql statement should be capitalized. Remember to wrap each node in a new line, so that the SQL statement can be displayed more clearly to prevent this kind of error.

 $sql="SELECT m.id,
                                   m.nav_name,
                                   m.nav_info,
                                   n.id iid,
                                   n.nav_name nnav_name
                                   FROM cms_nav m 
                                   LEFT JOIN cms_nav n  
                                   ON m.pid=n.id
                                   WHERE m.id=$this->id'
                                   or m.nav_name='$this->nav_name'
                                   limit 1";
Copy after login
This kind of error is $this->id ' is missing a single quote. . . . The above writing method is more standardized, because this way of writing can better identify problems and correct them.

2.parent is written as parent. . . How many letters are there

3. Write again

Look for errors:

1. Print the SQL statement to see if the syntax of the SQL statement is standardized, and whether the variables in it have been parsed or passed to the SQL statement

2. Comment the code that may cause the error, and then unravel it part by part to determine the error.

3. Write again

The above introduces how to reduce low-level errors in PHP code and the modification process, including aspects of the process. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template