From 98fece9d37c2de6a3fc8f51f0e5b98b3683617cd Mon Sep 17 00:00:00 2001 From: Ambrose Chua Date: Mon, 31 Oct 2016 01:22:02 +0800 Subject: [PATCH] Update references mysql_* to mysqli_* --- admin/index.php | 8 ++++---- connect.php | 8 ++------ detail.php | 12 ++++++------ get.php | 10 +++++----- index.php | 8 ++++---- like.php | 14 +++++++------- 6 files changed, 28 insertions(+), 32 deletions(-) diff --git a/admin/index.php b/admin/index.php index ee66465..b8b8ceb 100644 --- a/admin/index.php +++ b/admin/index.php @@ -39,15 +39,15 @@ if (isset($_POST["txt"]) && isset($_POST["tim"])) { include "../connect.php"; $mysql_table = MYSQL_TABLE; -$qry = "INSERT INTO `$mysql_table` (`id`, `txt`, `tim`) VALUES (NULL, '".mysql_escape_string(nl2br($txt.$extrl))."', '".mysql_escape_string($tim)."')"; -$result = mysql_query($qry); +$qry = "INSERT INTO `$mysql_table` (`id`, `txt`, `tim`) VALUES (NULL, '".mysqli_escape_string(nl2br($txt.$extrl))."', '".mysqli_escape_string($tim)."')"; +$result = mysqli_query($qry); if (!$result) { - die("Error! ".mysql_error()); + die("Error! ".mysqli_error()); } else { $allok = 1; } -mysql_close($link); +mysqli_close($link); } ?> diff --git a/connect.php b/connect.php index 88f7405..1153ac5 100644 --- a/connect.php +++ b/connect.php @@ -1,10 +1,6 @@ \ No newline at end of file +?> diff --git a/detail.php b/detail.php index 3580956..20e3c6b 100644 --- a/detail.php +++ b/detail.php @@ -5,11 +5,11 @@ include 'checklogin.php'; include "connect.php"; $mysql_table = MYSQL_TABLE; -$qry="SELECT * FROM `$mysql_table` WHERE `id`='".mysql_escape_string($_GET["id"])."'"; -$result=mysql_query($qry); +$qry="SELECT * FROM `$mysql_table` WHERE `id`='".mysqli_escape_string($_GET["id"])."'"; +$result=mysqli_query($qry); if($result) { - if(mysql_num_rows($result) == 1) { - $row = mysql_fetch_array($result); + if(mysqli_num_rows($result) == 1) { + $row = mysqli_fetch_array($result); ?>
\ No newline at end of file +mysqli_close($link); +?> diff --git a/get.php b/get.php index 5c873d3..26ca092 100644 --- a/get.php +++ b/get.php @@ -5,15 +5,15 @@ include 'checklogin.php'; include "connect.php"; $mysql_table = MYSQL_TABLE; -$qry="SELECT * FROM `$mysql_table` ORDER BY `$mysql_table`.`id` ASC LIMIT ".mysql_escape_string($_GET["lastid"])." , 1000"; -$result=mysql_query($qry); +$qry="SELECT * FROM `$mysql_table` ORDER BY `$mysql_table`.`id` ASC LIMIT ".mysqli_escape_string($_GET["lastid"])." , 1000"; +$result=mysqli_query($qry); $newlastid=$_GET["lastid"]; $jspo=array(); -while ($row = mysql_fetch_array($result)) { +while ($row = mysqli_fetch_array($result)) { $newlastid=$newlastid+1; array_push($jspo, array("txt"=>stripslashes($row["txt"]), "tim"=>$row["tim"], "id"=>$row["id"])); } echo json_encode(array("posts"=>$jspo, "lastid"=>$newlastid)); -mysql_close($link); -?> \ No newline at end of file +mysqli_close($link); +?> diff --git a/index.php b/index.php index 9de7163..0eeb95f 100644 --- a/index.php +++ b/index.php @@ -43,9 +43,9 @@ include 'checklogin.php'; include "connect.php"; $mysql_table = MYSQL_TABLE; $qry="SELECT * FROM `$mysql_table` ORDER BY `$mysql_table`.`id` DESC LIMIT 0, 30 "; - $result=mysql_query($qry); + $result=mysqli_query($qry); $iffirst=0; - while ($row = mysql_fetch_array($result)) { + while ($row = mysqli_fetch_array($result)) { $postlinked = stripslashes($row["txt"]); echo '
'.$postlinked.'
'.$row["tim"].'
'; if ($iffirst==0) { @@ -53,7 +53,7 @@ include 'checklogin.php'; $iffirst=1; } } - mysql_close($link); + mysqli_close($link); ?>
@@ -221,4 +221,4 @@ animationIn: 'bubble' - \ No newline at end of file + diff --git a/like.php b/like.php index d301aeb..56b7ae4 100644 --- a/like.php +++ b/like.php @@ -8,11 +8,11 @@ $stars=0; $starred=""; $mysql_table = MYSQL_TABLE; -$qrya="SELECT * FROM `$mysql_table` WHERE `id`='".mysql_escape_string($_GET["id"])."'"; -$resulta=mysql_query($qrya); +$qrya="SELECT * FROM `$mysql_table` WHERE `id`='".mysqli_escape_string($_GET["id"])."'"; +$resulta=mysqli_query($qrya); if($resulta) { - if(mysql_num_rows($resulta) == 1) { - $rowa = mysql_fetch_array($resulta); + if(mysqli_num_rows($resulta) == 1) { + $rowa = mysqli_fetch_array($resulta); $stars=$rowa["pluses"]; } } @@ -20,8 +20,8 @@ if($resulta) { $stars=$stars+1; if (isset($_GET["plusone"])) { - $qryb="UPDATE `$mysql_table` SET `pluses`='".($stars)."' WHERE `id`='".mysql_escape_string($_GET["id"])."'"; - $resultb=mysql_query($qryb); + $qryb="UPDATE `$mysql_table` SET `pluses`='".($stars)."' WHERE `id`='".mysqli_escape_string($_GET["id"])."'"; + $resultb=mysqli_query($qryb); if($resultb) { $starred="Thanks for a ★! "; } else { @@ -46,4 +46,4 @@ if (isset($_GET["plusone"])) { - \ No newline at end of file +