[英]CSV Upload to mySQL error with isset
Below is the current script I'm working on which should take a csv file uploaded by a user and insert it into mySQL. 以下是我正在使用的当前脚本,该脚本应将用户上传的csv文件插入到mySQL中。 I got the connection working, but I keep getting a server error as soon as I add the isset($_POST).
我已使连接正常工作,但是一旦添加isset($ _ POST),我就不断收到服务器错误。 I'd really appreciate some help if you see anything that might be causing the issue.
如果您发现任何可能导致此问题的信息,我将非常感谢您的帮助。
<?php
$conn = mysql_connect("localhost", "root", "root") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("db") or die(mysql_error());
echo "Connected to Database";
if(isset($_POST)['submit']))
{
$file = $_FILES['file']['tmp_name'];
$handle = fopen($file,"r");
while((fgetcsv($handle,1000,",")) !==false)
{
$storenumber = $fileop[0];
$zipcode = $fileop[1];
$sales = $fileop[2];
$sql = mysql_query("INSERT INTO test (store_number,zip_code,sales) VALUES('$storenumber','$zipcode','$sales')");
}
if($sql)
{
echo 'data uploaded';
}
}
?>
I think it's formatted incorrectly 我认为它的格式不正确
change if(isset($_POST)['submit']))
to if(isset($_POST['submit']))
将
if(isset($_POST)['submit']))
更改为if(isset($_POST['submit']))
if (isset ($_POST['submit'])) if(isset($ _POST ['submit']))
Just a parenthesis problem ;) 只是一个括号问题;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.