Flash(AS2.0)与php通讯 分享

9 篇文章 0 订阅
不好意思,贴上瘾了,没想到flash+php+mysql这么顺利就搞定了,自己赏跟白沙,哈哈Flash代码://第一桢var sendLoad:LoadVars = new LoadVars();var acceptLoad:LoadVars = new LoadVars();sendLoad.userName = "Billows";sendLoad.sendAndLoad("../php/conn_db.php", acceptLoad, "POST");//sendLoad.sendAndLoad("http://localhost/Flash&PHP/php/conn_db.php", acceptLoad, "POST");acceptLoad.onLoad = function(success) { if (success) { var myText = _root.createTextField("Billows", 0, 100, 100, 100, 100); myText.html = true; myText.htmlText = this.data; }};flash里和上面的差不多,这里用比较方便的LoadVars类来实现PHP代码:<?php$ userName = $ _POST['userName'];//Flash里传过来的值$ queryStr="SELECT * FROM username where name='".$ userName."'";//根据此变量查询mysql里数据mysql_connect("localhost","root","");//localhost本地数据库//root用户名//""密码mysql_select_db("test");//选择mysql里数据库$ qr = mysql_query($ queryStr);//执行查询$ nrows = mysql_num_rows($ qr); //取到符合查询条件的表里总的记录数for ($ i=0; $ i < $ nrows; $ i++){$ row = mysql_fetch_array($ qr); //取出数组$ data = $ row['password'].", ".$ row['name']."
"; //取出记录echo "&data=".urlencode($ data)."&";//输出到Flash}?>至于数据库我也接触的少,如果sql用的不熟的话,Mysql数据库,表,字段的建立可以用MySql-front来借助实现,很方便的。好了,php研究至此,以后要用的时候在研究吧。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值