简体   繁体   English

PHP MYSQL插入无法正常工作,不会收到任何错误

[英]PHP MYSQL insert doesn't work and receive no error

I have this PHP code , and i would insert a data in a table. 我有这个PHP代码,我会在表中插入数据。 I don't know why , it doesn't work. 我不知道为什么,它不起作用。 I receive no error from the query. 我没有从查询中收到任何错误。 If i print the $update_miner nothing is showed. 如果我打印$update_miner不会显示任何内容。 This is the code: 这是代码:

<?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");

?>

This is the table: 这是表:

在此处输入图片说明

you are missing one parenthesis at last 您最后缺少一个括号

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']."')")
                                                    ^ 

Not too sure but wouldn't use int to store a time. 不太确定,但是不会使用int来存储时间。 Int only goes up to a certain value and then will fail-or just store the highest value it can. Int只会上升到某个值,然后会失败-或仅存储它可以的最高值。 I think that might depend on your mysql version though. 我认为这可能取决于您的mysql版本。

The comment before is a good start and make sure you have connected to the database as well. 之前的注释是一个好的开始,并确保您也已连接到数据库。

So your $connection isn't false. 因此,您的$connection不是假的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM