国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php mysql數據保存實例

2024-05-04 21:58:26
字體:
來源:轉載
供稿:網友

這是一款老外寫的mysql php接受數據過來然后進行數據保存在mysql_real_escape_string(nl2br(strip_tags($_POST[/'comment/'])));我覺得寫得和我們有一點區別吧,代碼如下:

database config.php代碼如下:

  1. $db_host  = 'localhost'
  2. $db_user  = 'root'
  3. $db_pass  = ''
  4. $db_database = ''
  5.  
  6. $link = mysql_connect($db_host,$db_user,$db_passor die('unable to establish a db connection'); 
  7.  
  8. mysql_select_db($db_database,$link); 
  9. mysql_query("set names utf8"); 
  10.  
  11.  
  12. if(emptyempty($_post['comment'])) die("0"); 
  13. // if there isn't a comment text, exit 
  14.  
  15. $comment = mysql_real_escape_string(nl2br(strip_tags($_post['comment'])));//開源代碼Vevb.com 
  16. $user='demo'
  17. // this would be a nice place to start customizing - the default user 
  18. // you can integrate it to any site and show a different username. 
  19.  
  20. $addon=''
  21. if($_post['parent']) $addon=',parent='.(int)$_post['parent']; 
  22.  
  23. mysql_query("insert into wave_comments set usr='".$user."', comment='".$comment."', dt=now()".$addon); 
  24.  
  25. if(mysql_affected_rows($link)==1) 
  26.  echo mysql_insert_id($link); 
  27.  // if the insert was successful, echo the newly assigned id 
  28. else 
  29.  echo '0'

sql數據庫文件如下:

  1. -- 
  2. -- table structure for table `wave_comments` 
  3. -- 
  4.  
  5. create table `wave_comments` ( 
  6.   `id` int(11) not null auto_increment, 
  7.   `parent` int(11) not null default '0'
  8.   `usr` varchar(16) collate utf8_unicode_ci not null default ''
  9.   `comment` text collate utf8_unicode_ci not null
  10.   `dt` datetime not null default '0000-00-00 00:00:00'
  11.   primary key  (`id`), 
  12.   key `parent` (`parent`,`id`) 
  13. ) engine=myisam  default charset=utf8 collate=utf8_unicode_ci; 
  14.  
  15. -- 
  16. -- dumping data for table `wave_comments` 
  17. -- 
  18.  
  19. insert into `wave_comments` values(1, 0, 'tutorialzine''this is a demo for a tutorialzine tutorial about creating a google wave-like history slider.<br /><br />rnto get started, just drag the slider above, and this thread will be reverted to a past state.''2009-10-24 03:58:08'); 
  20. insert into `wave_comments` values(2, 0, 'curious''is html allowed in the comments?''2009-10-24 03:59:44'); 
  21. insert into `wave_comments` values(3, 2, 'tutorialzine''nope. also the messages in this demo are deleted every hour to prevent spamming.''2009-10-24 04:00:15'); 
  22. insert into `wave_comments` values(4, 1, 'tutorialzine''in this tutorial we are using <b>php</b>, <b>mysql</b>, <b>jquery</b> and <b>css教程</b>. the slider was created with <b>jquery ui</b>. <a href="http://111cn.net/2009/10/google-wave-history-slider-jquery/" target="_blank">view the tutorial</a>.''2009-10-24 04:01:34'); 
  23. insert into `wave_comments` values(5, 2, 'curious''thanks! also i noticed that you can click, rather than drag the slider.great!''2009-10-24 04:11:48'); 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 湖州市| 乳山市| 浠水县| 石首市| 宜阳县| 敦化市| 双辽市| 克什克腾旗| 慈利县| 南郑县| 桦川县| 清苑县| 惠州市| 井陉县| 建宁县| 元阳县| 沅陵县| 抚宁县| 徐水县| 麻城市| 江门市| 汶川县| 旬阳县| 响水县| 富宁县| 游戏| 日喀则市| 江北区| 肃北| 兴安盟| 松江区| 新安县| 玉龙| 郁南县| 弋阳县| 荥阳市| 平谷区| 嵊州市| 乌拉特后旗| 华宁县| 江达县|