-2

i'm diving into php and mysql and have a simple php scrip which tries to store planeID's and planeType's into a table called 'planes. When my table is completely empty, the script succeeds in inserting the planeID/planeType into the table. But afterwards i can't add a second entry.

here is what i have in my php file:

<?php
    require '../db/connect.php';

    $planeID = $_POST['planeID'];
    $planeType = $_POST['planeType'];

    $sql = "INSERT INTO `planes`
                (`planeType` , `planeID`)
            VALUES(
                " .$planeType. ",
                " .$planeID. "'
            )";
    mysql_query( $sql );

i don't get any error messages :/

4

1 回答 1

1

您缺少值周围的单引号。

<?php
    require '../db/connect.php';

    $planeID = $_POST['planeID'];
    $planeType = $_POST['planeType'];

    $sql = "INSERT INTO `planes`
                (`planeType` , `planeID`)
            VALUES(
                '" .$planeType. "', <--
                '" .$planeID. "'    <--
            )";
    mysql_query( $sql );
于 2013-06-26T19:49:19.313 回答