-1

所以我得到了这个错误:

Parse error: syntax error, unexpected '=' in C:\wamp\www\insert_data.php on line 9

在这条线上:

$std-id = $_POST['std_id'];

我的PHP代码是:

<?php

if ( isset($_POST['submitted'] ) )
{
include ('mysql_connect.php') ;

$std-id = $_POST['std_id'];
$std-name = $_POST['std_name'];
$std-year = $_POST['year'];
$std-degree = $_POST['degree'];

$sqlinsert = "INSERT INTO student ( ID , Name , Year ,  Degree ) VALUES (' $std-id ' ,   ' $std-name ' , ' $std-year ' , ' $std-degree ' ) ";

if (!mysql_query ( $dbcon, $sqlinsert ) ) {
die( ' error inserting new record ' ) ;
} // end of nested if statment

$newrecord = " 1 record added to the database " ;
} // end of the main if statement

?>
4

1 回答 1

7

变量名中不能有破折号。从手册

有效的变量名称以字母或下划线开头,后跟任意数量的字母、数字或下划线。

于 2013-05-24T04:15:24.350 回答