In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to deal with a php error". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "how to deal with a php error".
Encounter a php error solution: 1, check the syntax format; 2, view the function name; 3, convert the data type; 4, see whether the variable or function is named correctly; 5, modify the SQL statement; 6, check the definition of variables; 7, check whether the array key name is misspelled or undefined; 8, declare the character set.
This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer
Several common mistakes and solutions for beginners of php:
Error one:
Parse error: syntax error, unexpected...
This kind of error is PHP
Reasons and solutions:
Incorrect syntax format.
For example, every sentence should end with an English semicolon. If you don't write a semicolon or type it into a Chinese semicolon, you will report such an error. It can be avoided as long as we pay attention to the syntax format when writing the code.
Error 2:
Fatal error: Uncaught Error: Call to undefined function...
This error indicates that the code encountered a fatal error during execution, literally translated as: uncaught error: an undefined function was called
Reasons and solutions:
An undefined function was called. When we encounter this kind of error, we first need to check the error message, locate the line of the error code, and see if the function name is misspelled or whether the custom function is really undefined.
The solution is as follows:
Error 3:
Notice: Array to string conversion in...
This error is very easy for beginners to encounter, it is just an error prompt and does not affect the execution of the entire code. The array is in the first. Convert lines to strings
The solution is as follows:
This error is usually caused by the output of an array after echo, or when the array is concatenated as a string. (php is a weakly typed language, which automatically converts data types according to the needs of the environment.)
We just need to find the prompt line of code, process the array in advance and then perform the string operation.
Error 4:
Parse error: syntax error, unexpected'1' (T_LNUMBER), expecting variable
Reasons and solutions:
Navigate to the code that reported the error and see if the variable or function is named correctly.
Error five:
Warning: mysqli_fetch_assoc () expects parameter 1 to be mysqli_result, boolean given...
The error is literally translated as:
Warning: the mysqli_fetch_assoc function expects argument 1 to be the result set of mysqli, but gives a Boolean value. This error is a warning error and does not affect the execution of the program.
This error usually occurs when the database reads the result set data, for example, when we write the SQL statement to read the data from the database, we should return the result set and read the data to the result set. However, the result set is a Boolean value, so it is most likely that the SQL statement is miswritten, resulting in an execution error, and the result set becomes the execution result false.
Solution:
Check the SQL statement carefully, make sure there is no problem, and then submit it to the server for execution.
Error 6:
Notice: Undefined variable:...
The error is literally translated as: hint: no variable a defined
Reasons and solutions:
This error generally occurs when an undefined variable is used. When faced with this problem, we only need to carefully check whether the definition or spelling of the variable is correct.
Error 7:
Notice: Undefined index: username in...
The error literally translated into: hint: undefined index: username
Reasons and solutions:
This error typically occurs when undefined array elements are used. Associative arrays in php can access values using key names, and when prompted, they are also prompted as indexed arrays, so many beginners will misunderstand.
We just need to carefully check whether the array key name is misspelled or undefined.
Error 8: garbled code
Reasons and solutions:
Php generates html code because the character set is different from the character set displayed by the browser by default. We can add a response header to declare the character set at the top of the php script. For example, [header ('Content-Type:text/html; charset=utf-8')].
The above is all the contents of the article "how to deal with a php error". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.