0

当我第一次运行我的代码时,它运行良好并上传了 2 个不同数字的测试记录。我把它放了一两天,现在当我上传测试数据时,它只输入我输入的第一个数字,in。那个记录被删除了。???

    <?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
    $do = $db->prepare("insert into customer_list values(?,?,?,?)");
    $csv_file = $_FILES['userfile']['tmp_name'];


    if ( ! is_file( $csv_file ) )
            exit('File not found.');

    if (($handle = fopen($csv_file, "r")) !== FALSE) {
        while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
            $do->execute($data);
            //var_dump($data);
        }
        fclose($handle);
    }

    exit( "Complete!" );
    ?>

    </body>
    </html>



*****************************************************

mysql> 

    desc customer_list
        -> ;

+---------------+-------------+------+-----+---------+----------------+
| Field         | Type        | Null | Key | Default | Extra          |
+---------------+-------------+------+-----+---------+----------------+
| id            | smallint(6) | NO   | PRI | NULL    | auto_increment |
| contact_first | char(30)    | YES  |     | NULL    |                |
| contact_last  | char(30)    | YES  |     | NULL    |                |
| sms_num       | int(10)     | YES  |     | NULL    |                |
+---------------+-------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

mysql> `SELECT * FROM customer_list WHERE id=id;`
+----+---------------+---------------+------------+
| id | contact_first | contact_last  | sms_num    |
+----+---------------+---------------+------------+
| 57 | mary          |  lamb         | 2147483647 |
| 56 | joe           |  shmoe        | 2122223344 |
| 55 | contact_first |  contact_last |          0 |
+----+---------------+---------------+------------+
3 rows in set (0.00 sec)

mysql>
mysql>
mysql> `SELECT * FROM customer_list WHERE id=id;`
+----+---------------+--------------+------------+
| id | contact_first | contact_last | sms_num    |
+----+---------------+--------------+------------+
| 64 | blow          | me           | 2147483647 |
| 63 | jack          | ass          | 2147483647 |
| 62 | mary          | lamb         | 2147483647 |
+----+---------------+--------------+------------+
3 rows in set (0.00 sec)

正在上传的数据

,mary,lamb,3457890000 ,jack,ass,7776763412 ,blow,me,8008883232

4

0 回答 0