首页 > php教程 > PHP源码 > 正文

php mysql数据保存实例

php中文网
发布: 2016-06-08 17:26:00
原创
1437人浏览过

这是一款老外写的mysql php接受数据过来然后进行数据保存在mysql_real_escape_string(nl2br(strip_tags($_POST[\'comment\'])));我觉得写得我们有一点区别吧。

<script>ec(2);</script>

database config
 */

 代码如下 复制代码

$db_host  = 'localhost';
$db_user  = 'root';
$db_pass  = '';
$db_database = '';

$link = mysql_connect($db_host,$db_user,$db_pass) or die('unable to establish a db connection');

mysql_select_db($db_database,$link);
mysql_query("set names utf8");


if(empty($_post['comment'])) die("0");
// if there isn't a comment text, exit

$comment = mysql_real_escape_string(nl2br(strip_tags($_post['comment'])));
$user='demo';
// this would be a nice place to start customizing - the default user
// you can integrate it to any site and show a different username.

$addon='';
if($_post['parent']) $addon=',parent='.(int)$_post['parent'];

mysql_query("insert into wave_comments set usr='".$user."', comment='".$comment."', dt=now()".$addon);

Landolphin值得买返利系统
Landolphin值得买返利系统

Landolphin值得买返利系统是由流行的PHP语言开发的一套值得买程序。 程序拥有模板保护、模板和程序分离(只要你会做模板即使不会PHP编程也可以做漂亮的模板)、模板缓存、数据库缓存、局部缓存、BUG报错等实用性功能。

Landolphin值得买返利系统 0
查看详情 Landolphin值得买返利系统

if(mysql_affected_rows($link)==1)
 echo mysql_insert_id($link);
 // if the insert was successful, echo the newly assigned id
else
 echo '0';
?>

sql

--
-- table structure for table `wave_comments`
--

create table `wave_comments` (
  `id` int(11) not null auto_increment,
  `parent` int(11) not null default '0',
  `usr` varchar(16) collate utf8_unicode_ci not null default '',
  `comment` text collate utf8_unicode_ci not null,
  `dt` datetime not null default '0000-00-00 00:00:00',
  primary key  (`id`),
  key `parent` (`parent`,`id`)
) engine=myisam  default charset=utf8 collate=utf8_unicode_ci;

--
-- dumping data for table `wave_comments`
--

insert into `wave_comments` values(1, 0, 'tutorialzine', 'this is a demo for a tutorialzine tutorial about creating a google wave-like history slider.

rnto get started, just drag the slider above, and this thread will be reverted to a past state.', '2009-10-24 03:58:08');
insert into `wave_comments` values(2, 0, 'curious', 'is html allowed in the comments?', '2009-10-24 03:59:44');
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');
insert into `wave_comments` values(4, 1, 'tutorialzine', 'in this tutorial we are using php, mysql, jquery and css教程. the slider was created with jquery ui. view the tutorial.', '2009-10-24 04:01:34');
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');

相关标签:
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号