[英]PHP MYSQL insert doesn't work and receive no error
我有這個PHP代碼,我會在表中插入數據。 我不知道為什么,它不起作用。 我沒有從查詢中收到任何錯誤。 如果我打印$update_miner
不會顯示任何內容。 這是代碼:
<?php
session_start();
include("header.php");
$building['rock_miner'] =3;
$current_time = time();
$update_miner = mysqli_query($connection,"INSERT INTO `updates_queue` (`user_id`,`content`, `start_at`,`end_at`,`finished`,`old_level`) VALUES ('".$_SESSION['uid']."', 'rock_update', '".$current_time."','".$current_time."',0 ,'".$building['rock_miner']."'");
include("footer.php");
?>
這是表:
您最后缺少一個括號
INSERT INTO `updates_queue` (`user_id`,`content`, `start_at`,`end_at`,`finished`,`old_level`)
VALUES ('".$_SESSION['uid']."', 'rock_update', '".$current_time."',
'".$current_time."',0 ,'".$building['rock_miner']."')")
^
不太確定,但是不會使用int來存儲時間。 Int只會上升到某個值,然后會失敗-或僅存儲它可以的最高值。 我認為這可能取決於您的mysql版本。
之前的注釋是一個好的開始,並確保您也已連接到數據庫。
因此,您的$connection
不是假的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.