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²éѯִÐгɹ¦£¬Ôò·µ»Ø×ÊÔ´±êʶ·û£¬Ê§°ÜÊ
Ïà¹ØÎĵµ£º
ͨ³£¿ª·¢ÈËÔ±ÔÚд³ÌÐòµÄʱºò£¬ÍùÍùÊÇ°ÑÒѾÉè¼ÆºÃ»òÕß¹¹Ë¼ºÃµÄÔËËãÂß¼£¬Ö±½ÓÓñà³ÌÓïÑÔ·Òë³öÀ´¡£³ÌÐòÄÜ˳Àû±àÒëͨ¹ý£¬ÄÇÊǺÜÁîÈ˸ßÐ˵ÄÊÂÇé¡£Èç¹û´Ëʱ³ÌÐòµÄÔËÐÐʱ¼ä»¹ÄܽÓÊÜ£¬¾Í»á³Á½þÔÚд´úÂëµÄ³É¾Í¸Ðµ±ÖУ¬³£³£ÔÚÕâ¸ö¹ý³ÌÖкöÂÔ´úÂëµÄÓÅ»¯¡£Ö»Óе±³ÌÐòÔËÐÐËÙ¶ÈÊܵ½Ó°Ïìʱ£¬²Å»Ø¹ýÍ·È¥¿¼ÂÇÓÅ»¯µÄÊÂÇé¡£
ʲôÊÇËã·¨µÄʱ ......
ubuntuϸü¸ÄmysqlĬÈϱàÂë(×Ö·û¼¯)
http://blog.csdn.net/zzuduoduo/archive/2009/05/02/4142504.aspx
°²×°mysql
sudo apt-get install mysql-server #Ö±½Ó×Ô¶¯»ñµÃ¿ÉÓð汾
Ò²¿ÉÒÔÕâÑùд
sudo apt-get install mysql-server-5.0 #°²×°mysql·þÎñÆ÷5.0°æ±¾
°²×°ºó
/etc/init.d/mysql start (stop) ΪÆô¶¯ºÍÍ£Ö¹·þÎñÆ ......
(1)µÇ½µ½mysql
C:\Documents and Settings\Administrator>mysql -h localhost -u root -p
Enter password: *****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 69
Server version: 5.0.51a-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' fo ......
ÓÃphpÉú³ÉexcelÎļþ
<?
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");
echo "test1/t";
echo "test2/t/n";
echo "test1/t";
echo "test2/t/n";
echo "test1/t";
echo "test2/t/n";
echo "test1/t";
echo "test2/t/n";
echo "test1/t";
e ......
1.Èç¹ûÒ»¸ö·½·¨¿É¾²Ì¬»¯£¬¾Í¶ÔËü×ö¾²Ì¬ÉùÃ÷¡£ËÙÂÊ¿ÉÌáÉýÖÁ4±¶¡£
2.echo ±È print ¿ì¡£
3.ʹÓÃechoµÄ¶àÖزÎÊý£¨Òë×¢£ºÖ¸ÓöººÅ¶ø²»ÊǾäµã£©´úÌæ×Ö·û´®Á¬½Ó¡£
4.ÔÚÖ´ÐÐforÑ»·Ö®Ç°È·¶¨×î´óÑ»·Êý£¬²»ÒªÃ¿Ñ»·Ò»´Î¶¼¼ÆËã×î´óÖµ¡£
5.×¢ÏúÄÇЩ²»ÓõıäÁ¿ÓÈÆäÊÇ´óÊý×飬ÒÔ±ãÊÍ·ÅÄÚ´æ¡£
6.¾¡Á¿±ÜÃâʹÓÃ__get£¬__set£¬__auto ......