Php FAQ and solution 2-PHP source code

Source: Internet
Author: User
Ec (2); 15: What is UBB code? UBB code is a variant of HTML, Which is Ultimate & nbsp; Bulletin & nbsp; Board & nbsp; (a foreign BBS program, this program is also used in many places in China) using a special TAG. even if you disable & nbsp; HTML, you can use & nbsp; UBBCode? & Nbsp;. Maybe you prefer & nbsp; UBBCode? & Nbsp; instead of & nb script ec (2); script

15: What is UBB code?


UBB code is a variant of HTML. It is a special TAG used by Ultimate Bulletin Board (a BBS program in foreign countries, which is also used in many places in China.
Even if HTML is disabled, you can use UBBCode? . Maybe you want to use UBBCode more? Rather than HTML, even if the Forum allows HTML, it is safer to use less code.

There is an example in the UBB of Q3boy. You can run the test directly.


16: I want to modify the MySQL user and password.

First, we need to declare that, in most cases, modifying MySQL requires the root permission in mysql,
Therefore, you cannot change the password unless you request the Administrator.

Method 1
Phpmyadmin is the simplest. Modify the user table of the mysql database,
But don't forget to use the PASSWORD function.

Method 2
Use mysqladmin, which is a special case stated above.
Mysqladmin-u root-p password mypasswd
After entering this command, you need to enter the original root password, and then the root password will be changed to mypasswd.
Change the root in the command to your username, and you can change your password.
Of course, if your mysqladmin cannot connect to mysql server, or you cannot execute mysqladmin,
This method is invalid.
In addition, mysqladmin cannot clear the password.

The following methods are used at the mysql prompt and must have the root permission of mysql:
Method 3
Mysql> insert into mysql. user (Host, User, Password)
VALUES ('%', 'Jeffrey ', PASSWORD ('biscuit '));
Mysql> FLUSH PRIVILEGES
Specifically, this is adding a user with the username jeffrey and password biscuit.
I wrote this example in mysql Chinese reference manual.
Be sure to use the PASSWORD function, and then use flush privileges.

Method 4
Similar to method Sany, but the REPLACE statement is used.
Mysql> replace into mysql. user (Host, User, Password)
VALUES ('%', 'Jeffrey ', PASSWORD ('biscuit '));
Mysql> FLUSH PRIVILEGES

Method 5
Use the set password statement,
Mysql> set password for jeffrey @ "%" = PASSWORD ('biscuit ');
You must also use the PASSWORD () function,
However, you do not need to use flush privileges.

Method 6
Use the GRANT... identified by statement
Mysql> grant usage on *. * TO jeffrey @ "%" identified by 'biscuit ';
Here, the PASSWORD () function is unnecessary and does not need to be flush privileges.

Note: PASSWORD () [not] implements PASSWORD encryption in the same way as Unix PASSWORD encryption.


17: I want to know which website he connected to this page



PHP code :--------------------------------------------------------------------------------

// Output is available only when input through the super connection
Echo $ _ SERVER ['HTTP _ referer'];
?>

--------------------------------------------------------------------------------



18: What do you need to pay attention to when data is put into the database and retrieved?

Warehouse receiving
$ Str = addslashes ($ str );
$ SQL = "insert into 'tab' ('content') values ('$ str ')";
Warehouse picking
$ Str = stripslashes ($ str );
Display time
$ Str = htmlspecialchars (nl2br ($ str ));





19: how to read the current address bar Information



PHP code :--------------------------------------------------------------------------------

$ S = "http: // {$ _ SERVER ['HTTP _ host']}: {$ _ SERVER ["SERVER_PORT"]} {$ _ SERVER ['script _ name']} ";
$ Se = '';
Foreach ($ _ GET as $ key => $ value ){
$ Se. = $ key. "=". $ value ."&";
}
$ Se = Preg_Replace ("/(. *) & $/", "$1", $ se );
$ Se? $ Se = "? ". $ Se :"";
Echo $ s ."? $ Se ";
?>
--------------------------------------------------------------------------------




20: I clicked the back button. Why didn't I enter anything?

This is because you have used the session.
Solution:

PHP code :--------------------------------------------------------------------------------

Session_cache_limiter ('Private, must-revalidate ');
Session_start ();
...........
..........
?>

--------------------------------------------------------------------------------



21: how to display IP addresses in Images


PHP code :--------------------------------------------------------------------------------

Header ("Content-type: image/png ");
$ Img = ImageCreate (180,50 );
$ Ip = $ _ SERVER ['remote _ ADDR '];
ImageColorTransparent ($ img, $ bgcolor );
$ BgColor = ImageColorAllocate ($ img, 0x2c, 0x6D, 0xAF); // background color
$ Shadow = ImageColorAllocate ($ img, 250,0, 0); // shadow color
$ TextColor = ImageColorAllocate ($ img, oxff); // font color
ImageTTFText ($ img, 10, 0, 78, 30, $ shadow, "d:/windows/fonts/Tahoma. ttf", $ ip); // display the background
ImageTTFText ($ img, 10, 0, 25, 28, $ textColor, "d:/windows/fonts/Tahoma. ttf", "your ip is". $ ip); // display IP
ImagePng ($ img );
Imagecreatefrompng ($ img );
ImageDestroy ($ img );
?>

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.