Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//载入数据库文件
require("data.php");
$sql="select * from soul order by rand( ) limit 1";
$row=mysql_fetch_assoc(mysql_query($sql));
$row=mysqli_fetch_assoc(mysql_query($conn,$sql));
//输出json
echo json_encode(array('code'=>1,'data'=>$row['title']));
?>
6 changes: 3 additions & 3 deletions data.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$conn=mysql_connect("localhost","symhytwg_fun","wahaha2019"); //连接数据库地址、用户名、密码
mysql_query("set names 'utf8'"); //数据库编码
mysql_select_db("sy_nows"); //数据库名称
$conn = mysqli_connect("db_hostname","db_username","db_password"); //连接数据库地址、用户名、密码
//mysql_query("set names 'utf8'"); //数据库编码
mysqli_select_db($conn,"sy_nows"); //数据库名称
?>
8 changes: 4 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@


<?php
$sql="select * from soul order by rand( ) limit 1";
$rs=mysql_query($sql);
$sql = "select * from soul order by rand( ) limit 1";
$rs = mysqli_query($conn,$sql);
?>
<?php
while($rows=mysql_fetch_assoc($rs))
while($rows = mysqli_fetch_assoc($rs))
{
?>

Expand Down Expand Up @@ -78,4 +78,4 @@
</div>

</body>
</html>
</html>