开发者

Data is not being stored in the database

My code is getting the ID from another, after I get that ID I will insert it to another table. The thing is it's not working, any idea why?

<?php 

session_start(); 
include("Connection.php");
    if (isset($_POST['submit'])){  
    $name = $_POST['customerName'];
    mysql_query("INSERT INTO  `starbucks`.`orders` (
`ID` ,
`NAME` ,
`开发者_如何学GoTOTAL_PRICE` ,
`TOTAL_ITEMS` ,
`TIME`
)
VALUES (
'' ,  '$name',  '', '',NOW())");

$_SESSION['user'] = $name; 
}
$dTime = time();
$myValue = isset($_REQUEST['dValue']) ?$_REQUEST['dValue'] : '';
echo "The time is: {$dTime}<br/>
The choice is {$myValue} ";

$sql = "Select * from product where NAME = '{$myValue}'";
 $result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)){
    $price = $row['PRICE'];
    $id = $row['ID'];
    echo $id;
    $sql2 ="INSERT INTO starbucks`.order_details (ID, ORDER_ID, PRODUCT_ID, QTY) VALUES ('', '', '$id', '1')";
   $result2 = mysql_query($sql2);
}
?>


extra back tick in the INSERT, either add another or remove

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜