-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
无标题文档学号
姓名
系级
电话
=======================================
insertyy.php
========================================
//------[ 基本设定) ]-------
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "";
$mysql_database = "sqllanxing";
//-------
//插入sql数据
$sql = "INSERT INTO `sqllanxing`.`communication` (`serial` ,`number` ,`name` ,`class` ,`email` ,`phone` ,`time` )
VALUES (
'' , '$number', '$name', '$class', '$email', '$phone', 'NOW()'
);";
$conn=mysql_connect( $mysql_server_name, $mysql_username, $mysql_password);
mysql_select_db($mysql_database,$conn);
$result = mysql_query($sql);
$id = mysql_insert_id();
mysql_close($conn);
?>
执行后,只是在数据库中插入一行空数据
如果把
VALUES (
'' , '$number', '$name', '$class', '$email', '$phone', 'NOW()'
);";
改为
VALUES (
'' , '11, 'aa', '$class', '$email', '$phone', 'NOW()'
);";
11,aa可以在数据库中显示
更改为$sql = "INSERT INTO `sqllanxing`.`communication` (
`serial` ,
`number` ,
`name` ,
`class` ,
`email` ,
`phone` ,
`time`
)
VALUES (
NULL , '$_POST[number]', '4', '', '', '', NOW( )
);";
后
提示有下面错误:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in F:\insertyy.php on line 22
展开