PHPÖеÄMYSQL³£Óú¯Êý×ܽá
PHPÖеÄMYSQL³£Óú¯Êý×ܽá
1¡¢mysql_connect()-½¨Á¢Êý¾Ý¿âÁ¬½Ó
¸ñʽ£º
resource mysql_connect([string hostname [:port] [:/path/to/socket] [, string username] [, string password]])
Àý£º
$conn = @mysql_connect("localhost", "username", "password") or dir("²»ÄÜÁ¬½Óµ½Mysql Server");
˵Ã÷£ºÊ¹ÓøÃÁ¬½Ó±ØÐëÏÔʾµÄ¹Ø±ÕÁ¬½Ó
2¡¢mysql_pconnect()-½¨Á¢Êý¾Ý¿âÁ¬½Ó
¸ñʽ£º
resource mysql_pconnect([string hostname [:port] [:/path/to/socket] [, string username] [, string password]])
Àý£º
$conn = @mysql_pconnect("localhost", "username", "password") or dir("²»ÄÜÁ¬½Óµ½Mysql Server");
˵Ã÷£ºÊ¹ÓøÃÁ¬½Óº¯Êý²»ÐèÒªÏÔʾµÄ¹Ø±ÕÁ¬½Ó£¬ËüÏ൱ÓÚʹÓÃÁËÁ¬½Ó³Ø
3¡¢mysql_close()-¹Ø±ÕÊý¾Ý¿âÁ¬½Ó
Àý£º
$conn = @mysql_connect("localhost", "username", "password") or die("²»ÄÜÁ¬½Óµ½Mysql Server");
@mysql_select_db("MyDatabase") or die("²»ÄÜÑ¡ÔñÕâ¸öÊý¾Ý¿â£¬»òÊý¾Ý¿â²»´æÔÚ");
echo "ÄãÒѾÁ¬½Óµ½MyDatabaseÊý¾Ý¿â";
mysql_close();
4¡¢mysql_select_db()-Ñ¡ÔñÊý¾Ý¿â
¸ñʽ£º
boolean mysql_select_db(string db_name [, resource link_id])
Àý£º
$conn = @mysql_connect("localhost", "username", "password") or die("²»ÄÜÁ¬½Óµ½Mysql Server");
@mysql_select_db("MyDatabase") or die("²»ÄÜÑ¡ÔñÕâ¸öÊý¾Ý¿â£¬»òÊý¾Ý¿â²»´æÔÚ");
5¡¢mysql_query()-²éѯMySQL
¸ñʽ£º
resource mysql_query (string query, [resource link_id])
Àý£º
$linkId = @mysql_connect("localhost", "username", "password") or die("²»ÄÜÁ¬½Óµ½Mysql Server");
@mysql_select_db("MyDatabase") or die("²»ÄÜÑ¡ÔñÕâ¸öÊý¾Ý¿â£¬»òÕßÊý¾Ý¿â²»´æÔÚ");
$query = "select * from MyTable";
$result = mysql_query($query);
mysql_close();
˵Ã÷£ºÈôSQL²éѯִÐгɹ¦£¬Ôò·µ»Ø×ÊÔ´±êʶ·û£¬Ê§°ÜÊ
Ïà¹ØÎĵµ£º
MySQL´¥·¢Æ÷
Ò»¡¢ MySQL´¥·¢Æ÷¸ÅÄî
MySQL5.0ÒÔÉÏ°æ±¾Ö§³Ö´¥·¢Æ÷£¬´¥·¢Æ÷ÊÇÓë±íÓйصÄÃüÃûÊý¾Ý¿â¶ÔÏ󣬵±±í³öÏÖÌض¨Ê¼þʱ£¬½«¼¤»î¸Ã¶ÔÏó¡£
¶þ¡¢ MySQL´¥·¢Æ÷Óï·¨
CREATE TRIGGER trigger_name trigger_time trigger_event
ON tbl_name FOR EACH ROW trigger_stmt
trigger ......
¡¡ÎÒÃÇ°ÑÏÂÔصÄÈý¸öÈí¼þ°ü·Åµ½/var/localĿ¼Ï£¨ÕâÊDZÊÕ߸öÈ˵ÄÏ°¹ß£©£¬ËüÃǶ¼ÊÇtar.gz°ü£¬¿ÉÒÔÓÃÃüÁîtar -xzpvf °üÃû£¬°ÑËüÃÇÔÚµ±Ç°Ä¿Â¼£¨/var/local/£©Öн⿪£º
cd /var/local
tar -xzpvf mysql-4.0.15.tar.gz
tar -xzpvf php-4.3.3.tar.gz
tar -xzpvf httpd-2.0.47.tar.gz
¡¡¡¡½â°üºó¿ÉÒÔ¿ªÊ¼½øÈëÕýʽ°²×°¡£ ......
<?php
echo "<br>";
?>
<?php
function GetIP()
{
if(!empty($_SERVER["HTTP_CLIENT_IP"]))
$cip = $_SERVER["HTTP_CLIENT_IP"];
else if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"]))
$cip = $_SERVER["HTTP_X_FORWARDED_FOR"];
else if(!empty($_SERVER ......
ÕâÁ½ÌìÔÚµ·¹ÄPHP£¬È¥ecshopºÍphpwindÏÂÔØÁËÒ»¸öÉ̳ǺÍÒ»¸öÂÛ̳¡£Á½¸ö¶¼ÐèÒª°²×°mysqlµÄ·þÎñÆ÷£¬ÓÚÊÇÎÒ°´Õս̳̽øÐа²×°¡£½á¹û·¢ÏÖÿ´Î¶¼Êǵ½Á¬½ÓÊý¾Ý¿âµÄµØ·½¾Í±ä³É¿Õ°×Ò³ÁË¡£ËÀ»îÕÒ²»³öÀ´ÎÊÌâ¡£ºóÀ´ÔÚÓཨµÄÖ¸µ¼Ï£¬·¢ÏÖÔÀ´ÊÇPHPµÄ°æ±¾¹ý¸ß¡£ÕæÊÇÓôÃÆ¡£
ÏÖÔÚÎÒ°ÑÎÒ×î½üÅäÖõĹý³Ìд³öÀ´¡£
ËùÐèÈí¼þ£º
apache_2.2.14-wi ......