PHP向mysql中插入数据的方法
时间:2021-07-01 10:21:17
帮助过:2人阅读
require "database.php"
;
2
3 $po_code = "YMWF2015-6-25-1"
;
4 $customer = "youmei"
;
5 $confirm_date = "2015-6-25"
;
6 $delivery_date = "2015-7-25"
;
7
8 $create_order_sql = "INSERT INTO `ld_crm`.`order` (`id`, `po_code`, `customer`, `confirm_date`, `delivery_date`) VALUES (NULL, ‘
$po_code‘, ‘
$customer‘, ‘
$confirm_date‘, ‘
$delivery_date‘)"
;
//注意此处前面的`ld_crm`中并不是单引号而是esc下面那个按键的符号。后面的VALUES中的变量不能用双引号代替单引号,单引号前面不能有\转义字符
9 10 11 if ($db_conn->query($create_order_sql) === TRUE) { 12 echo "New record created successfully"; 13 } else { 14 echo "Error: " . $create_order_sql . "<br>" . $db_conn->error; 15 }
PHP向mysql中插入数据的方法
标签: