php¶ÁÊý¾Ý¿âÂÒÂë
<?php
// Á¬½Ó£¬Ñ¡ÔñÊý¾Ý¿â
$dbconn = pg_connect("host=localhost dbname=publishing user=www password=foo")
or die('Could not connect: ' . pg_last_error());
// Ö´ÐÐ SQL ²éѯ
$query = 'SELECT * from authors';
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
// Óà HTML ÏÔʾ½á¹û
echo "<table>\n";
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// ÊͷŽá¹û¼¯
pg_free_result($result);
// ¹Ø±ÕÁ¬½Ó
pg_close($dbconn);
?>
http://php.chinaunix.net/manual/zh/ref.pgsql.php
ps:Ò³ÃæÉêÃ÷±àÂ룺ÔÚHTML´úÂëHEADÀïÃ棬¿ÉÒÔÓÃ<meta http-equiv="Content-Type" content="text/html;
charset="XXX" />À´¸æËßä¯ÀÀÆ÷ÍøÒ³²ÉÓÃÁËʲô±àÂ룬ĿǰÖÐÎÄÍøÕ¾¿ª·¢ÖÐÖ÷ÒªÓõÄÊÇGB2312ºÍUTF-8Á½ÖÖ±à
Âë¡£
ÌáÈ¡µÄÊý¾Ý±àÂëÓë "<META http-equiv=Content-Type content="text/html; charset=gb2312">" ÍøÒ³Ò³Ãæ
±àÂëÒ»ÖÂ,ÕâÑùÍøÒ³ÖоÍûÓÐÂÒÂëÁË¡£
$db->query("set client_encoding to 'gbk'");
Èç¹û²»Ïë¸ÄÅäÖÃÎļþ
ÔÚÒ³Ãæ´úÂëÖмÓÈëЧ¹ûÒ»Ñù!
ÔÀ´ÊÇÕâÑù£¬¿ÉÒÔÉèÖÿͻ§¶Ë±àÂëµÄ£¬ÎÒÒ»Ö±¸øÊý¾Ý¿â¶¨ÒåΪ
[code]
CREATE DATABASE hent
WITH OWNER = postgres
ENCODING = 'EUC_CN'
TABLESPACE = pg_default;
[/code]
¸ÄÈý¸öÅäÖÃÎļþ¼´¿É.Æäʵ´ó¼Ò¶¼ÖªµÀÊÇÄÄÈý¸öÁË.
php.ini my.cnf httpd.conf ¾ÍºÃÁË.°Ñ±àÂëÓйصĶ¼ÉèÖÃ³É utf-8¼´¿É.
µ«ÊÇ»¹²»ÐÐ.ÒòΪÎÒ°²×°ÁË. php-mbstring .ËùÒÔÔÚphp.iniÀïÃæÒ»¶¨Òª¿ªÆô mbstring ÇÒ±àÂëÒ²ÒªÉèÖóÉ
utf-8.
php.ini ;default_charset = "iso-8859-1" ¸Ä³É default_charset = "UTF-8"
<?
header('content-Type=text/html;charset=utf-8')
php
echo "t
Ïà¹ØÎĵµ£º
Éý»ªÌṩÖÕÉíÃâ·ÑASP+access PHP+mysqlÐéÄâÖ÷»ú
Ò»£ºÉý»ªÍøÂç¿Æ¼¼ÓÐÏÞ¹«Ë¾,ÓëÉý»ªÍ¬ÔÚÕ¾³¤ÖÕÉíÃâ·Ñ¿Õ¼ä·ö³Ö¼Æ»®.
1¡¢×ð¾´µÄÓû§ÄúºÃ,Ò²ÐíÄú»¹ÔÚΪÿÄêÒ»½»µÄ¿Õ¼ä·ÑÓ÷¢³î,Ò²ÐíÄúÏë»ñµÃÒ»¸ö¸üÓÅÖʵĿռäÈ´²»ÏëͶÈëÌ«¶à,´ÓÏÖÔÚÆð ÕâЩÎÊÌ⽫ÓÈжø½â→Éý»ªÍøÂç←ÓëÉý»ªÍ¬ÔÚÕ¾³¤·ö³Ö¼Æ»®È«ÃæÆô¶¯¡£
2¡¢Ã»ÓÐ×¢²á¹«Ë¾ ......
½øÐÐÎļþµÄ¶ÁºÍд£¬ÏÈ´ò¿ªÒ»¸öÎļþ£¬È»ºó¿ªÊ¼¶Á»òÕßдÎļþ£¬×îºóÔÙ¹ØϵÕâ¸öÎļþ×ÊÔ´¡£
È磬ÎļþµÄ¶Á²Ù×÷£º
<?php
$file = fopen('your file path','r');
while(!feof($file)){ //µ±Ã»ÓжÁÈ¡µ½Îļþ½á⣬¼ÌÐøÑ»·¶ÁÈ¡²Ù×÷
$line = fgets($file); //¶ÁÈ¡µ½Ò»ÐеÄÄÚÈÝ
echo $line.'<br/>';
}
fclose($file) ......
ÎÊÌ⣺
ÄãÏë´´½¨Ò»¸ö¶ÔÏ󣬲¢ÔÚÆäÖÐÌí¼ÓһЩÊôÐÔ£¬µ«ÊÇÄãÈ´²»Ïë°ÑËü×÷Ϊһ¸öÃ÷È·µÄÀàÕýʽµØ¶¨ÒåËü¡£ÕâÒ»µãÔÚһЩÇé¿öÏÂÊÇÏ൱ÓÐÓõģ¬ÀýÈçµ±ÄãÐèÒª¶¨ÒåÒ»¸ö·½·¨À´·µ»Ø´øÓÐijЩÊôÐÔ£¨²»È·¶¨µÄ£©µÄ¶ÔÏóʱ£¬¾ÍÈçͬ´Ómysql_fetch_object( ) »òÕß imap_header( )µÄʹÓÃÒ»Ñù¡£
һάÊý×é,ÎÒÏÖÔÚÌرðϲ»¶°ÑËüд³É¶ÔÏó,ÒòΪ¼üÅÌ´ ......
ÒýÓÃhttp://www.icnote.com/Mysql-php-connector/
ÓÉÓÚ¹«Ë¾µÄ·þÎñÆ÷¿ªÊ¼Ö»ÊÇÓÃÓÚjavaµÄÖ§³Ö£¬×°ÁËapache£¬mysql£¬php£¬µ«ÊÇphpµÄ°²×°Ã»ÓжÔmysql½øÐÐÖ§³Ö£¬½ñÌì¶ÔËû½øÐÐÁËÀ©Õ¹£¬¼Ç¼ÈçÏ¡£
Ê×ÏÈ£¬°²×°mysqlºÍphpµÄÁ¬½ÓÀ©Õ¹£¬ÐèÒªÒÔÏ°ü¡£¿ÉÒÔÔÚhttp://rpmfind.net/
ÕÒµ½£¬¸ù ......