繁体   English   中英

插入数据库给出语法错误

[英]Insert to database gives syntax error

如果有人能告诉我为什么我在此代码中遇到语法错误,我将不胜感激:

if(isset($_POST['submit']))
                                    {   
$dbcon = mysqli_connect("localhost","user1","test1","tutorial");



$stored_file = $_FILES["file"]["name"];

$query="INSERT INTO store (filname, uppladdare, titel) VALUES


**Line 136->**('$_POST[**file**]$stored_file','$_POST[uppladdare]','$_POST[titel]')";
    if(!mysqli_query($dbcon ,$query));
                                        }

注意:未定义的索引:第136行中的/ Applications / XAMPP / xamppfiles / htdocs / projekt webb / laddaupp.php中的文件

该功能运行良好,我可以存储所需的所有数据。 但是我仍然遇到错误。 我总是可以通过使用report_error来“修复”此问题。 但是我更喜欢从错误中学习。

/谢谢

编辑:星星不是编码的一部分。 只是为了显示错误发生的地方!

最终结果:

$ query =“ INSERT INTO store(filname,uppladdare,titel)VALUES('$ stored_file','$ _ POST [uppladdare]','$ _ POST [titel]')”;

感谢您的朋友们的回答!:)

我认为您可以使用变量$stored_file刚刚存储文件名的位置

$query="INSERT INTO store (filname, uppladdare, titel) 
VALUES ('$stored_file','$_POST[uppladdare]','$_POST[titel]')";

没有$_POST['file']$stored_file$_POST由于错误说没有指数$_POST['file']

暂无
暂无

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

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