我的代码没有错误,但没有数据进入数据库。第 63 行是它应该进行上传的地方,但 var_dump 并没有多大帮助。php pdo 我的代码没有错误,但没有数据进入数据库。第 63 行是它应该进行上传的地方,但 var_dump 并没有多大帮助。php pdo
<?php
require_once('auth.php');
require_once('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Index</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/subnav.js"></script>
</head>
<body>
<h1>Welcome <?php echo $_SESSION['SESS_FIRST_NAME'];?></h1>
<a href="member-profile.php">My Profile</a> | <a href="logout.php">Logout</a>
<p>Welcome to the TPC Holdings SMS Campaign Builder</p>
<p></p>
<ul class="topnav">
<li><a href="#">Home</a></li>
<li>
<a href="#">Tutorials</a>
<ul class="subnav">
<li><a href="#">Sub Nav Link</a></li>
<li><a href="#">Sub Nav Link</a></li>
</ul>
</li>
<li>
<a href="#">Resources</a>
<ul class="subnav">
<li><a href="#">Sub Nav Link</a></li>
<li><a href="#">Sub Nav Link</a></li>
</ul>
</li>
<li><a href="#">About Us</a></li>
<li><a href="#">Submit</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
<p></p>
<p>View your stats</p>
<p>Change your ip</p>
<p>Pay your bill</p>
<form enctype="multipart/form-data" method="POST">
<input name="userfile" type="file">
<input type="submit" value="Upload">
</form>
<?php
$dsn = "mysql:host=$host;port=$port;dbname=$dbname"; //Data Source Name = Mysql
$db = new PDO($dsn, $db_username, $db_password); //Connect to DB
$csv_file = $_FILES['userfile']['tmp_name'];
if ( ! is_file( $csv_file ) )
exit('File not found.');
if (($handle = fopen( $csv_file, "r")) !== FALSE)
{
$data = fgetcsv($handle, 1000, ",");
$q = "INSERT INTO customer_list (CSV) VALUES (contact_first, contact_last, sms_num)";
//$q = "INSERT INTO customer_list (CSV) VALUES (?,?,?)";
//var_dump($csv_file);
$do = $db->prepare($q);
$do->execute();
var_dump('CSV');
//var_dump($do);
}
fclose($handle);
exit( "Complete!" );
//exit( $sql );
?>
</body>
</html>