我是一个完整的代码nooby,几个月前在我的服务器主板死亡之前建立了一个基本网站。我只是重建了服务器并复制了我备份到桌面的所有网站/数据库代码。据我所知,php代码和数据库设置之间的一切都是一样的。
除了输入数据时,我的网站工作率为90%。我收到错误#34;等待进入"反对预期的"新纪录成功创造"。相对if语句在下面代码的最底部 。
有没有人有任何线索为什么在输入所有我的正确数据之后它不会触发"新记录成功创建"?如果它意味着任何代码在我的桌面上工作正常,除非我做了一些非常愚蠢的事情,我将所有内容复制/意外地发送到此服务器:(
<?php
//Connect to database
include('database.php');
//grab user logged in for database insertion
$user_check = $_SESSION['login_user'];
$ses_sql = mysqli_query($dbcon,"select username from t_login where username = '$user_check' ");
$row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
$login_session = $row['username'];
// Create DB Variable
$login_session = $row['username'];
$excercisename = (isset($_POST['excercisename']) ? $_POST['excercisename'] : null);
$setcount = (isset($_POST['setcount']) ? $_POST['setcount'] : null);
$rep1 = (isset($_POST['rep1']) ? $_POST['rep1'] : null);
$rep2 = (isset($_POST['rep2']) ? $_POST['rep2'] : null);
$rep3 = (isset($_POST['rep3']) ? $_POST['rep3'] : null);
$rep4 = (isset($_POST['rep4']) ? $_POST['rep4'] : null);
$rep5 = (isset($_POST['rep5']) ? $_POST['rep5'] : null);
$rep6 = (isset($_POST['rep6']) ? $_POST['rep6'] : null);
$rep7 = (isset($_POST['rep7']) ? $_POST['rep7'] : null);
$rep8 = (isset($_POST['rep8']) ? $_POST['rep8'] : null);
$weight1 = (isset($_POST['number1']) ? $_POST['number1'] : null);
$weight2 = (isset($_POST['number2']) ? $_POST['number2'] : null);
$weight3 = (isset($_POST['number3']) ? $_POST['number3'] : null);
$weight4 = (isset($_POST['number4']) ? $_POST['number4'] : null);
$weight5 = (isset($_POST['number5']) ? $_POST['number5'] : null);
$weight6 = (isset($_POST['number6']) ? $_POST['number6'] : null);
$weight7 = (isset($_POST['number7']) ? $_POST['number7'] : null);
$weight8 = (isset($_POST['number8']) ? $_POST['number8'] : null);
$cardio = (isset($_POST['cardio']) ? $_POST['cardio'] : null);
$duration = (isset($_POST['duration']) ? $_POST['duration'] : null);
$weight = (isset($_POST['weight']) ? $_POST['weight'] : null);
$comments = (isset($_POST['comments']) ? $_POST['comments'] : null);
//Execute the insert statement
if(!empty($excercisename)){
$sql = "INSERT INTO t_workout (username, excercisename, setcount, set1reps, set2reps, set3reps, set4reps, set5reps, set6reps, set7reps, set8reps, set1weight, set2weight, set3weight, set4weight, set5weight, set6weight, set7weight, set8weight, cardio, cardio_dur, weight, comments)
VALUES ('$login_session', '$excercisename', '$setcount', '$rep1', '$rep2', '$rep3', '$rep4', '$rep5', '$rep6', '$rep7', '$rep8', '$weight1', '$weight2', '$weight3', '$weight4', '$weight5', '$weight6', '$weight7', '$weight8', '$cardio', '$duration', '$weight', '$comments')";
}
if($weight > 0){
$sql = "INSERT INTO t_workout (username, weight)
VALUES ('$login_session', '$weight')";
}
if(isset($sql)){
if ($dbcon->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Waiting for entry.";
}
}
$dbcon->close();
?>
答案 0 :(得分:0)
甜蜜的怜悯我很抱歉看到这个哈哈的人。
我解决了。代码和一切都很好(好吧,代码是业余爱好者)。
问题在于wampserver,在我的mysql.ini文件中有一个分号注释掉sql-mode。我只是删除了分号,现在它可以工作了。我不知道ini文件中的sql模式是什么...但是我在几个月前在ini文件中编辑过的东西是在比较我所有的wampserver配置文件时发现的。
<强>; SQL模式=&#34;&#34; 强>