PHP FAQ and workaround two up

Source: Internet
Author: User
Tags flush php code

15: What is UBB code


UBB code is a variant of HTML, is Ultimate Bulletin Board (a foreign BBS program, there are many places in the domestic use of this program) a special tag.
Even if you prohibit the use of HTML, you can use Ubbcode? Maybe you'd prefer to use Ubbcode? Instead of HTML, even if the forums allow HTML, it's safer to use less code.

Q3boy's UBB has an example to run the test directly


16: I want to modify the MySQL user, password

The first thing to declare is that in most cases, MySQL is required to have root privileges in MySQL,
Therefore, the general user cannot change the password unless the administrator is requested.

Method One
Using phpMyAdmin, this is the easiest, to modify the MySQL library's user table,
But don't forget to use the password function.

Method Two
Using Mysqladmin, this is a special case of the previous declaration.
Mysqladmin-u root-p Password mypasswd
After entering this command, you need to enter the original password for root, and then the root password will be changed to MYPASSWD.
Change the command root to your username, and you can change your password.
Of course, if your mysqladmin is not connected to MySQL server, or you have no way to execute mysqladmin,
Then this method is ineffective.
And mysqladmin can't empty the password.

The following methods are used at the MySQL prompt and must have the root permissions of MySQL:
Method Three
Mysql> INSERT into Mysql.user (Host,user,password)
VALUES ('% ', ' Jeffrey ', PASSWORD (' biscuit '));
Mysql> FLUSH Privileges
To be exact, this is adding a user, the username is Jeffrey, and the password is biscuit.
There is this example in the MySQL Chinese reference manual, so I wrote it.
Note that you want to use the password function, and then use flush privileges.

Method Four
And method Three, just use the Replace statement
Mysql> REPLACE into Mysql.user (Host,user,password)
VALUES ('% ', ' Jeffrey ', PASSWORD (' biscuit '));
Mysql> FLUSH Privileges

Method Five
Using the Set Password statement,
Mysql> SET PASSWORD for jeffrey@ "%" = PASSWORD (' biscuit ');
You must also use the password () function,
But you don't need to use flush privileges.

Method Six
Use Grant ... Identified by statement
Mysql> GRANT USAGE on *.* to jeffrey@ "%" identified by ' biscuit ';
Here the password () function is unnecessary and does not require the use of flush privileges.

Note: PASSWORD () [is not] the password encryption is performed in the same way as the UNIX password encryption.


17: I want to know which website he is connecting to this page



PHP Code:--------------------------------------------------------------------------------

<?php
Must go through the super connection to have output
Echo $_server[' Http_referer '];
?>

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



18: Data into the database and take out to display in the page need to pay attention to what

When in storage
$str =addslashes ($STR);
$sql = "INSERT INTO ' tab ' (' Content ') VALUES (' $str ')";
When you are out of the library
$str =stripslashes ($STR);
When displayed
$str =htmlspecialchars (NL2BR ($STR));





19: How to read the current address bar information



PHP Code:--------------------------------------------------------------------------------

<?php
$s = "http://{$_server[' http_host ']}:{$_server[" server_port "]}{$_server[' Script_name ']}";
$se = ';
foreach ($_get as $key => $value) {
$se. = $key. " = ". $value." & ";
}
$se =preg_replace ("/(. *) &$/", "$", $se);
$se? $se = "?". $se: "";
echo $s. "? $se ";
?>
--------------------------------------------------------------------------------




20: I click on the Back button, why the missing items before filling

This is because you use the session.
Solution:

PHP Code:--------------------------------------------------------------------------------

<?php
Session_cache_limiter (' Private, must-revalidate ');
Session_Start ();
...........
..........
?>

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



21: How to display the IP address in the picture


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,oxff,oxff); Font Color
Imagettftext ($img, 10,0,78,30, $shadow, "D:/windows/fonts/tahoma.ttf", $IP); Show background
Imagettftext ($img, 10,0,25,28, $textColor, "D:/windows/fonts/tahoma.ttf", "Your IP is". $ip); Show 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.