Today, we will give you a big Summary of the headaches for PHP beginners. The 14 questions raised below hope to help PHP beginners.
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 get familiar with the new writing method.
2. An error occurs when apache2 uses the get method to pass Chinese parameters under Win32.
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 in win32 cannot 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 thus the session cannot be used.
Change it to an absolute path, for example, session. save_path = c: windowstemp.
4. Display error messages
When php. when display_errors = On and error_reporting = E_ALL of ini, all errors and prompts are displayed. It is best to enable this function during debugging for error correction, 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. Email cannot be sent by mail () under Win32
Sendmail configured in linux can be sent. in win32, you need to call the smtp server to send an email and modify php. SMTP = ip // ip address of ini is an smtp server without verification (difficult to find on the Internet ), 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 instance, 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:
Step 1: first install php-4.2.3-installer.exein www.php.net. You can also find the latest version. Before installing php-4.2.3-installer.exe, ensure that your IIS6.0 is started and accessible. After installation, go to the default website --> application configuration;
Step 2: click web Service Extension> Create web service extension;
Step 3: add the extension --> php;
Step 4: Find the php.exe path and add it;
Step 5: click OK;
Step 6: select the php service extension and click Allow.
10. Sometimes SQL statements do not work and database operations fail.
The simplest debugging method is echo the SQL statement to see if the variable value can be obtained.
1