<?php require_once('../connect.php'); mysqli_query("set names utf-8"); //把傳遞過來的信息入庫,在入庫之前對所有的信息進行校驗。 print_r($_POST); $title = $_POST['title']; $times = $_POST['times']; $source = $_POST['source']; $column = $_POST['column']; $content = $_POST['content']; $dateline = time(); if(!isset($_POST['title']) || empty($_POST['title'])) { echo "<script>alert('標題不能為空'); window.location.href='article.add.php'</script>"; }elseif(!isset($_POST['column']) || empty($_POST['column'])){ echo "<script>alert('欄目不能為空'); window.location.href='article.add.php'</script>"; }else{ $con = mysqli_connect("localhost", "root", "root", "info"); //準備SQL語句,查詢用戶名 $insertsql = "SELECT info FROM article WHERE title = '$title'"; //執(zhí)行SQL語 $ret = mysqli_query($con,$insertsql); if (!$ret) { die('Query failed'); } } ?>
Troubleshoot, first check if there is any problem with the connection, and then check the problem with the query statement
It’s my mysqli_query that always returns false