我刚刚创建了一个.php文件,遗憾的是我的sql查询无法在我的网络托管上运行,但.php文件运行正常。所以问题是,我的SQL查询无法执行
它说:
Post Gagal或Post失败(英文)
你能告诉我为什么我有一个SQL错误以及如何解决这个错误
这是我的PHP代码
date_default_timezone_set("Asia/Bangkok");
ob_start();
session_start();
require 'connection.php';
// if session is not set this will redirect to login page
if( !isset($_SESSION['user']) ) {
header("Location: loginpanel.php");
exit;
}
// select loggedin users detail
$res=mysqli_query($conn,"SELECT * FROM akun_admin WHERE idadmin=".$_SESSION['user']);
$userRow=mysqli_fetch_array($res);
if ( isset($_POST['btn-post']) ) {
$error = false;
// clean user inputs to prevent sql injections
$jd = trim($_POST['jd']);
$jd = strip_tags($jd);
$sa = trim($_POST['sa']);
$sa = strip_tags($sa);
$note = trim($_POST['note']);
$note = strip_tags($note);
$genre = trim($_POST['genre']);
$genre = strip_tags($genre);
$ps = trim($_POST['ps']);
$ps = strip_tags($ps);
$ep14 = trim($_POST['1Link480p']);
$ep17 = trim($_POST['1Link720p']);
$ep1 = trim($ep14.'-'.$ep17);
$ep1 = strip_tags($ep1);
$ep24 = trim($_POST['2Link480p']);
$ep27 = trim($_POST['2Link720p']);
$ep2 = trim($ep24.'-'.$ep27);
$ep2 = strip_tags($ep2);
$ep34 = trim($_POST['3Link480p']);
$ep37 = trim($_POST['3Link720p']);
$ep3 = trim($ep34.'-'.$ep37);
$ep3 = strip_tags($ep3);
$ep44 = trim($_POST['4Link480p']);
$ep47 = trim($_POST['4Link720p']);
$ep4 = trim($ep44.'-'.$ep47);
$ep4 = strip_tags($ep4);
$ep54 = trim($_POST['5Link480p']);
$ep57 = trim($_POST['5Link720p']);
$ep5 = trim($ep54.'-'.$ep57);
$ep5 = strip_tags($ep5);
$ep64 = trim($_POST['6Link480p']);
$ep67 = trim($_POST['6Link720p']);
$ep6 = trim($ep64.'-'.$ep67);
$ep6 = strip_tags($ep6);
$ep74 = trim($_POST['7Link480p']);
$ep77 = trim($_POST['7Link720p']);
$ep7 = trim($ep74.'-'.$ep77);
$ep7 = strip_tags($ep7);
$ep84 = trim($_POST['8Link480p']);
$ep87 = trim($_POST['8Link720p']);
$ep8 = trim($ep84.'-'.$ep87);
$ep8 = strip_tags($ep8);
$ep94 = trim($_POST['9Link480p']);
$ep97 = trim($_POST['9Link720p']);
$ep9 = trim($ep94.'-'.$ep97);
$ep9 = strip_tags($ep9);
$ep104 = trim($_POST['10Link480p']);
$ep107 = trim($_POST['10Link720p']);
$ep10 = trim($ep104.'-'.$ep107);
$ep10 = strip_tags($ep10);
$ep114 = trim($_POST['11Link480p']);
$ep117 = trim($_POST['11Link720p']);
$ep11 = trim($ep114.'-'.$ep117);
$ep11 = strip_tags($ep11);
$ep124 = trim($_POST['12Link480p']);
$ep127 = trim($_POST['12Link720p']);
$ep12 = trim($ep124.'-'.$ep127);
$ep12 = strip_tags($ep12);
$ep134 = trim($_POST['13Link480p']);
$ep137 = trim($_POST['13Link720p']);
$ep13 = trim($ep134.'-'.$ep137);
$ep13 = strip_tags($ep13);
$ep144 = trim($_POST['14Link480p']);
$ep147 = trim($_POST['14Link720p']);
$ep14 = trim($ep144.'-'.$ep147);
$ep14 = strip_tags($ep14);
$ep154 = trim($_POST['15Link480p']);
$ep157 = trim($_POST['15Link720p']);
$ep15 = trim($ep154.'-'.$ep157);
$ep15 = strip_tags($ep15);
$ep164 = trim($_POST['16Link480p']);
$ep167 = trim($_POST['16Link720p']);
$ep16 = trim($ep164.'-'.$ep167);
$ep16 = strip_tags($ep16);
$ep174 = trim($_POST['17Link480p']);
$ep177 = trim($_POST['17Link720p']);
$ep17 = trim($ep174.'-'.$ep177);
$ep17 = strip_tags($ep17);
$ep184 = trim($_POST['18Link480p']);
$ep187 = trim($_POST['18Link720p']);
$ep18 = trim($ep184.'-'.$ep187);
$ep18 = strip_tags($ep18);
$ep194 = trim($_POST['19Link480p']);
$ep197 = trim($_POST['19Link720p']);
$ep19 = trim($ep194.'-'.$ep197);
$ep19 = strip_tags($ep19);
$ep204 = trim($_POST['20Link480p']);
$ep207 = trim($_POST['20Link720p']);
$ep20 = trim($ep204.'-'.$ep207);
$ep20 = strip_tags($ep20);
$ep214 = trim($_POST['21Link480p']);
$ep217 = trim($_POST['21Link720p']);
$ep21 = trim($ep214.'-'.$ep217);
$ep21 = strip_tags($ep21);
$ep224 = trim($_POST['22Link480p']);
$ep227 = trim($_POST['22Link720p']);
$ep22 = trim($ep224.'-'.$ep227);
$ep22 = strip_tags($ep22);
$ep234 = trim($_POST['23Link480p']);
$ep237 = trim($_POST['23Link720p']);
$ep23 = trim($ep234.'-'.$ep237);
$ep23 = strip_tags($ep23);
$ep244 = trim($_POST['24Link480p']);
$ep247 = trim($_POST['24Link720p']);
$ep24 = trim($ep244.'-'.$ep247);
$ep24 = strip_tags($ep24);
$tp = date("Y-m-d");
$wp = date("h:i:sa");
$ap = $userRow['alias'];
function generateRandomString($length = 50) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
$postID = generateRandomString();
// if there's no error, continue to signup
if(!empty($jd)) {
$res = mysqli_query($conn,"INSERT INTO postperepisode1_12 (idpost, judulpost, tanggal, waktu, adminposting, genre, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1`, 18, 19, 20, 21, 22, 23, 24, note, sinopsis) VALUES ('$postID', '$jd', '$tp', '$wp', '$ap', '$genre', '$ep1', '$ep2', '$ep3', '$ep4', '$ep5', '$ep6', '$ep7', '$ep8', '$ep9', '$ep10', '$ep11', '$ep12', '$ep13', '$ep14', '$ep15', '$ep16', '$ep17', '$ep18', '$ep19', '$ep20', '$ep21', '$ep22', '$ep23', '$ep24', '$sa', '$note')");
if ($res) {
$errTyp = "success";
$errMSG = "Posting Berhasil";
} else {
$errTyp = "danger";
$errMSG = "Post Gagal";
}
}
}
?>
答案 0 :(得分:0)
是的,我明白了,但这是你的自定义错误,也许你可以打印你的sql并在执行中执行 mysql客户端。你可以先查看mysqli_error($ conn)