Home > Backend Development > PHP Tutorial > 有哪位高手用过新浪云啊新手一枚

有哪位高手用过新浪云啊新手一枚

WBOY
Release: 2016-06-13 12:04:06
Original
794 people have browsed it

有谁用过新浪云啊,求助啊,新手一枚
把数据库在新浪平台里建好了以后,怎样和自己托管的代码连接起来啊,在php里用mysql_connect()貌似不行啊
比如建立一个文件conn.php,代码如下

<br /><?php<br />$conn =  mysql_connect( "w.rdc.sae.sina.com.cn:3307", "SAE_MYSQL_USER", "SAE_MYSQL_PASS") or die("数据库链接错误");<br />mysql_select_db("bbs", $conn);<br />mysql_query("set names 'GBK'"); //使用GBK中文编码;<br />?><br />
Copy after login

之后每次浏览的时候就会出现
SAE_Warning: mysql_connect() [function.mysql-connect]: this app is not authorised in conn.php on line 2

SAE_Warning: mysql_connect() [function.mysql-connect]: in conn.php on line 2
数据库链接错误

应该怎么弄啊,唉。。。。。

------解决方案--------------------
"SAE_MYSQL_USER", "SAE_MYSQL_PASS" ???
SAE_MYSQL_USER, SAE_MYSQL_PASS
------解决方案--------------------
SAE_MYSQL_USER, SAE_MYSQL_PASS

这个是让你数据库用户名和密码的

不是让你照原样填上去的
------解决方案--------------------
SAE_MYSQL_USER, SAE_MYSQL_PASS

这个两个是SAE 自带的常量,你直接写没问题。。问题是。。
mysql_connect( "w.rdc.sae.sina.com.cn:3307"

也要写成。。。

$con = mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
------解决方案--------------------
这里有两种办法。
第一,使用sae里面自带的变量。
第二,使用sae提供的SaeMysql类来操作
------解决方案--------------------
SEA直接查询就可以了啊

<br />$mysql = new SaeMysql();<br />$sql = "SQL语句";<br />$data = $mysql->getData( $sql );<br />
Copy after login


SEA返回的是一个多维数组
$data[XXX]['XXX'];
$mysql->closeDb();

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template