1.phpä¸è½½å®ç½ï¼
2.Ubuntu下的源码运输抢单源码c++连接数据库
3.å¦ä½ä½¿ç¨VCå¼åMySQL
phpä¸è½½å®ç½ï¼
phpwebæä¹ä¸è½½
1ãå¨æµè§å¨ä¸æç´¢PHPï¼è¿å ¥phpå®ç½ã
2ãç¹å»Downloadsé项ï¼è¿å ¥ä¸è½½é¡µé¢ã
3ãéæ©ä¸ä¸ªéåçPHPçæ¬ï¼ç¶åç¹å»é¡µé¢ä¸çWindowsdownloadsã
4ãç¹å»zipæé®ï¼åç¹å»ä¸è½½æé®å³å¯ã
å¦ä½å¨æ¬å°æºä¸çphp?åå¤å·¥ä½é¦å è¦ä¸è½½å¦ä¸è½¯ä»¶ï¼æ¨èå°å®ç½ä¸è½½ï¼å¦æä½ æ¯åæä¸æ ·åªæ¯æµè¯ï¼é£ä¹å°skycn.comä¸è½½å§ï¼è¿æ ·æ¯è¾å¿«ã
Apache
ææµè¡çHTTPæå¡å¨è½¯ä»¶ä¹ä¸ãå¿«éãå¯é ãå¯éè¿ç®åçAPIæ©å±ï¼Perl/Python解éå¨å¯è¢«ç¼è¯å°æå¡å¨ä¸ï¼å®å ¨å è´¹ï¼å®å ¨æºä»£ç å¼æ¾ã
æä¸è½½çæ¯forWindowsçæ¬ï¼ç®åææ°çæ¬æ¯ï¼2.0.
PHP
PHPæ¯ä¸ç§HTMLå åµå¼çè¯è¨ãèPHPç¬ç¹çè¯æ³æ··åäºCãJavaãPerl以åPHPå¼çæ°è¯æ³ãå®å¯ä»¥æ¯CGIæè Perlæ´å¿«éçæ§è¡å¨æç½é¡µã
æä¸è½½çæ¯forWindowsçæ¬ï¼ç®åææ°çæ¬æ¯ï¼5.0.4
MySQL
æ¯ä¸ä¸ªå¤çº¿ç¨çï¼ç»æåæ¥è¯¢è¯è¨(SQL)æ°æ®åºæå¡å¨ãSQLå¨ä¸çä¸æ¯ææµè¡çæ°æ®åºè¯è¨ãMySQLçæ§è¡æ§è½é常é«ï¼è¿è¡é度é常快ï¼å¹¶é常容æ使ç¨ã
æä¸è½½çæ¯forWindowsçæ¬ï¼ç®åææ°çæ¬æ¯ï¼5.0.4Beta
phpMyAdmin
phpMyAdminæ¯ä¸ä¸ªç¨PHPç¼åçï¼å¯ä»¥éè¿äºèç½æ§å¶åæä½MySQLãéè¿phpMyAdminå¯ä»¥å®å ¨å¯¹æ°æ®åºè¿è¡æä½ã
æä¸è½½çæ¯forWindowsçæ¬ï¼ç®åææ°çæ¬æ¯ï¼2.6.2-pl1
å®è£ apacheåPHP
ä¸é¢æ¯æçå®è£ è®°å½ï¼
éæ©ç«¯å£ï¼å°apacheå®è£ å¨e:\apacheä¸ã
é ç½®apacheéçmendedï¼éå½å为php.ini并æ·è´å°windowsç®å½ä¸ã
NTFSä¸è®°å¾ç»æå¡å¨å¼PHP.iniç读æéã
æ¥æ¾extension_diråé¢çæ¹ä¸ºe:/php/ext
æ¥æ¾WindowsExtensionsï¼æä¸é¢æä¸æç;extension=php_***.dllçåå·å»æï¼å°±æ¯æ¯æç»ä»¶äºãææextension=php_gd2.dllextension=php_mbstring.dllextension=php_mysql.dllçåå·å»æäºã
php5é»è®¤ä¸æ¯æmysqläº,æ以è¦ä¸ºä»æ·»å æ¯æ,é¤äºextension=php_mysql.dllå»åå·ä¹å¤ï¼å¨phpç®å½éæ个libmysql.dllæ件,æå®å¤å¶å°ç³»ç»çsystemæ件夹ä¸,å¤å¶php.iniå°windowsç®å½ä¸ã
æ¤æ¶PHPç¯å¢åºæ¬å·²ç»é ç½®æå
å¨WEBæ ¹ç®å½é建ä¸ä¸ªå为test.phpçæ件å 容å¦ä¸
echophpinfo();?éæ°å¯å¨apacheæå¡ï¼ç¨æµè§å¨æå¼
å¦æå¯ä»¥çå°phpé ç½®è¾åºä¿¡æ¯å°±æåäº
å®è£ mysql
å°mysqlå®è£ å°æå®ç®å½ï¼ç¶åå®è£ ç¨åºä¼å¼å¯¼ä½ ä¸æ¥æ¥é ç½®ãä¸è¿å¥æªçæ¯æåä»»å¡æ 没æåºç°Mysqlçå¾æ ã
ä¿®æ¹mysqlæ°æ®åºçrootå¯ç
ç¨cmdè¿å ¥å½ä»è¡æ¨¡å¼è¾å ¥å¦ä¸å½ä»¤:(注:d:\mysql为mysqlå®è£ ç®å½)
cdd:\mysql\bin
mysqladmin-uroot-ppassword
å车åºç°
Enterpassword:(注:è¿æ¯å«ä½ è¾å ¥åå¯ç .åå®è£ æ¶å¯ç 为空,æ以ç´æ¥å车å³å¯)
æ¤æ¶mysqlä¸è´¦å·rootçå¯ç 被æ¹ä¸ºå®è£ å®æ¯
é ç½®php.ini并æµè¯mysql
æ¾å°extension_dir=./æ¹ä¸ºextension_dir=e:/php/ext
æ¾å°
;extension=php_mysql.dll
å°';'å»ææ¹ä¸º
extension=php_mysql.dll
æ¾å°
;session.save_path=/tmp
å°';'å»æè®¾ç½®ä½ ä¿åsessionçç®å½ï¼å¦
session.save_path=e:/php/session_temp
éå¯apacheæå¡
å¨Webæ ¹ç®å½ä¸å»ºç«testdb.phpæ件å 容å¦ä¸ï¼
php$link=mysql_connect('localhost','root','');
if(!$link)echofail;
elseechosuccess;
mysql_close();
ç¨æµè§å¨æå¼å¦æè¾åºsuccesså°±OKäº
phpmyadminçå®è£ é ç½®
å°phpMyAdmin-V2.6.2-pl1.zip解åå°WEBæ ¹ç®å½ä¸å»ï¼éå½åæ件夹为phpmyadminæå ¶å®
æå¼phpmyadminç®å½ä¸çconfig.inc.php
æ¾å°
$cfg['Servers'][$i]['user']='root';
$cfg['Servers'][$i]['password']='';
åå«å¡«ä¸ç¨æ·ååå¯ç
linuxphpç½ç«æä¹å®è£
ä¸ãå®è£ Apache2.2.
1ãå°å®ç½ä¸è½½
2ã解å
tar-zxvfpilerfoundin$Path
ç´æ¥è¿è¡yuminstallgccï¼å®è£ Gccå³å¯
第ä¸ä¸ªé®é¢ä¸ºï¼pcre-configforlibpcrenotfound
解å³æ¹æ³å°±æ¯ä¸è½½prceå®è£ å ï¼åAPR类似ï¼å®è£ å°/usr/local/pcreæ件夹ä¸é¢å³å¯ãPS:fedoraä¸å®è£ c++ç¼è¯å¨g++çå½ä»¤ä¸ºï¼yuminstallgcc-c++ã
5ãç¼è¯
make
6ãå®è£
makeinstall
7ãå¯å¨ï¼éå¯ååæ¢ï¼å åæ¢å°å®è£ å®æåçç®å½/usr/local/apache2/bin
./apachectl-kstart
./apachectl-krestart
./apachectl-kstop
8ãé ç½®æ件(满足æåºæ¬çé ç½®)
ç¼è¾/usr/local/apache2/conf/press.Z
AddTypeapplication/x-gzip.gz.tgz
å¨åé¢æ·»å ï¼
AddTypeapplication/x-/soft/.htmå¤ä¸è½½ï¼ï¼å½ç¶ä½ ææ´æ°ççæ¬æ´å¥½ï¼æ³¨æéæ©âå®å ¨å®è£ âï¼åªæè¿æ ·æä¼å®è£ VCç¼è¯æ¶éè¦ç头æ件çï¼ãå®è£ åæä¼è¿è¡æå¡å¨é ç½®ï¼ä½ å¯ä»¥è®¾ç½®ä½ çæå¡å¨ç»éå¯ç ï¼ä¹å¯ä»¥ä¸è®¾ç½®å¯ç ã
äºãVC6.0ç设置
ï¼1ï¼æå¼VC6.0 å·¥å ·æ Toolsèåä¸çOptionsé项ï¼å¨Directoriesçæ ç¾é¡µä¸å³è¾¹çâShow directories
for:âä¸æå表ä¸éä¸âIncludefilesâï¼ç¶åå¨ä¸é´å表æ¡ä¸æ·»å ä½ æ¬å°å®è£ MySQLçincludeç®å½è·¯å¾ãï¼æçæ¯D:\Program
Files\MySQL\MySQL Server 5.0\includeï¼ã
ï¼2ï¼å¨ä¸é¢è¯´å°çâShow directories for:âä¸æå表ä¸éä¸âLibrary
filesâï¼ç¶åæ·»å ä½ æ¬å°å®è£ MySQLçLibç®å½è·¯å¾ãLibç®å½ä¸è¿ædebugåopt两个ç®å½ï¼å»ºè®®édebugãï¼æçæ¯D:\Program
Files\MySQL\MySQL Server 5.0\lib\debugï¼ã
ï¼3ï¼å¨âProject settings->Link:Object/library modulesâéé¢æ·»å âlibmysql.libâã
ï¼4ï¼å¨stdafx.héé¢æ·»å å¦ä¸çå 容ï¼
#include "mysql.h"
#include "winsock.h" // å¦æç¼è¯åºé,åæ该è¡æ¾å°#include "mysql.h"ä¹å
#pragma comment(lib,"libmySQL.lib") // å¦æå¨éå ä¾èµé¡¹éå·²å¢å ,åå°±ä¸è¦æ·»å äº
ï¼5ï¼å»ºè®®å°âlibmySQL.libãlibmySQL.dllâæ·å°ä½ æ建çå·¥ç¨çç®å½ä¸ã
ä¸ãæ°æ®åºã表çå建
æå¼âå¼å§->ææç¨åº->MySQL->MySQL Server 5.0->MySQL Command Line
Client.exeâï¼å¦æ没æ设置å¯ç å°±ç´æ¥æå车ï¼ä¼æ示æå¡å¨å¯å¨æåã
mysql> SHOW DATABASES;//æ¾ç¤ºææçæ°æ®åºï¼æ³¨æä¸å®è¦ æ²â;âååæå车
mysql> CREATE DATABASE mydb;//å建æ°æ®åºmydb
mysql> USE mydb;//éæ©ä½ æå建çæ°æ®åºmydb
mysql> SHOW TABLES; //æ¾ç¤ºæ°æ®åºä¸ç表
mysql> CREATE TABLE mytable (username VARCHAR(), visitelist VARCHAR(), remark VARCHAR());//å建ä¸ä¸ªè¡¨mytable: ç¨æ·åï¼è®¿é®å表ï¼å¤æ³¨
mysql> DESCRIBE mytable;//æ¾ç¤ºè¡¨çç»æ
åãVCç¼ç¨
MYSQL mysql; //æ°æ®åºè¿æ¥å¥æ
mysql_init (&mysql);
if(!mysql_real_connect(&mysql,"localhost","root",NULL,"mydb",,NULL,0)) { //mydbä¸ºä½ æå建çæ°æ®åºï¼ä¸ºç«¯å£å·ï¼å¯èªè¡è®¾å®
AfxMessageBox("æ°æ®åºè¿æ¥å¤±è´¥");
return FALSE;
}
ï¼1ï¼å®ç°æ·»å åè½
CString strUsername,strList,strRemark,strSQL;
strSQL.Format("insert into mytable(username,visitelist,remark) values(\'%s\',\'%s\',\'%s\')", strUsername,strList,strRemark);//注æä¸å®è¦åå¨ä¸è¡ï¼èä¸å¿ é¡»è¦æ\'\'
if(mysql_real_query(&mysql,(char*)(LPCTSTR)strSQL,(UINT)strSQL.GetLength())!=0){
AfxMessageBox("å¢æ·»å¤±è´¥");
}
ï¼2ï¼å®ç°ä¿®æ¹åè½
CString strUsername,strList,strRemark,strSQL,str_PreName;//str_PreNameç¨äºè®°å½æ³è¦ä¿®æ¹çè¡ï¼è¯¦æ 请çæºä»£ç
strSQL.Format("update mytable set username=\'%s\',visitelist=\'%s\', remark=\'%s\' where username=\'%s\'",strUsername,strList,strRemark,str_PreName);
if(mysql_real_query(&mysql,(char*)(LPCTSTR)strSQL,(UINT)strSQL.GetLength())!=0){
AfxMessageBox("ä¿®æ¹å¤±è´¥");
}
ï¼3ï¼å®ç°å é¤åè½
CString strSQL;
strSQL.Format("delete from mytable where username=\'%s\'",str_PreName);//å¿ é¡»è¦æ\'\'
if(mysql_real_query(&mysql,(char*)(LPCTSTR)strSQL,(UINT)strSQL.GetLength())!=0){
AfxMessageBox("å é¤å¤±è´¥");
}
ï¼4ï¼è¯»åè¡¨æ ¼å 容å°CListCtrlæ§ä»¶m_list
m_list.DeleteAllItems();
char *ch_query;
ch_query="select * from mytable";
if(mysql_real_query(&mysql,ch_query,(UINT)strlen(ch_query))!=0){
AfxMessageBox("æ°æ®åºä¸è¡¨æ ¼åºé");
}
CString str;
MYSQL_RES *result;
MYSQL_ROW row;
if(!(result=mysql_use_result(&mysql))){
AfxMessageBox("读åæ°æ®é失败");
}
int i=0;
while(row=mysql_fetch_row(result)){
str.Format("%s",row[0]);
m_list.InsertItem(i,str);
str.Format("%s",row[1]);
m_list.SetItemText(i,1,str);
str.Format("%s",row[2]);
m_list.SetItemText(i,2,str);
i++;
}
mysql_free_result(result);
ï¼5ï¼å ³éæ°æ®åº
mysql_close(&mysql);//æ好åå°OnDestroy()å½æ°ä¸
äºãç»æè¯
æ¬æå¨å ä½ç½åçå·¥ä½åºç¡ä¸è¯¦ç»ä»ç»äºMySQLçå®è£ ãè°è¯ï¼ä»¥åå¦ä½ç¨VCè¿è¡ç¼è¯ï¼å®ç°æ°æ®çâæ·»å ãä¿®æ¹ãå é¤âçåè½ï¼å¯ä»¥ä¸ºå¨MySQLçVCç¼ç¨ä¸æå°å°æçæå们æä¾ä¸ç¹å¸®å©ï¼å¨æ¤åå ä½ç½å表示æè°¢ï¼