14 most headaches for PHP beginners

Source: Internet
Author: User

[1] variables cannot be transferred between pages.
The get, post, and session automatic global variables are disabled in the latest php version. Therefore, to obtain and submit the variables from the previous page, use $ _ GET ['foo']. $ _ POST ['foo'], $ _ SESSION ['foo. Of course, you can also change the automatic global variable to on (php. ini is changed to register_globals
= On); Considering compatibility, it is better to force yourself to familiarize yourself with the new writing method.
[2] in Win32, an error occurs when apache2 uses the get method to pass Chinese parameters:
Test. php? A = Hello & B = You
Passing parameters will cause an internal error.
Solution: "test. php? A = ". urlencode (Hello)." & B = ". urlencode (you can also)
[3] The session under win32 does not work normally
Php. ini default session. save_path =/tmp
This is obviously a configuration in linux. in win32, php cannot read or write session files, and the session cannot be used. You can change it to an absolute path, for example, session. save_path.
= C: windows emp
[4] displaying error messages
When display_errors of php. ini is On and error_reporting =
All errors and prompts will be displayed during E_ALL. It is best to enable it for error correction during debugging. If you use php to write errors, most of them are about undefined variables. A prompt is displayed before the variable is assigned a value. The solution is to detect or block the variable.
For example, if $ foo is displayed, you can use if (isset ($ foo) echo $ foo or echo @ $ foo.
[5] Win32 mail () cannot send email
Sendmail configured in linux can be sent. in win32, you need to call the smtp server to send an email and modify the SMTP = ip address of php. ini.
// The ip address is an smtp server without verification (it is hard to find it online)
The best solution for sending emails in php is to directly send emails to the recipient's email server using socket instead of forwarding the server.
[6] if the password is not set for the newly installed mysql, use update mysql. user set password = "yourpassword" where
User = "root" Change Password
[7] header already sent
This error usually occurs when you use the HEADER. It may be due to several reasons: 1. You PRING or ECHO before using the HEADER. 2. you have a blank line before the current file. 3. you may INCLUDE a file. This error may also occur if there are blank lines at the end of the file or the output .!

[8] php. ini has not changed.
Restart the web server, such as IIS and Apache, and then apply the latest settings.
[9] install php on 2003 (for how to install ISAPI, please advise)
Php4isapi. dll of PHP4 seems to be in conflict with 2003. It can only be installed in CGI Mode.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.