0

コードを最初に実行したとき、問題なく動作し、異なる番号の 2 つのテスト レコードをアップロードしました。1日か2日放置しましたが、テストデータをアップロードすると、最初に入力した数字だけが入力されます.そのレコードは削除されます. ????

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

アップロード中のデータ

,メアリー,ラム,3457890000 ,ジャック,お尻,7776763412 ,ブロー,私,8008883232

4

0 に答える 0