Home >Backend Development >PHP Tutorial > Parse error: syntax error, unexpected T_VARIABLE on line 九

Parse error: syntax error, unexpected T_VARIABLE on line 九

WBOY
WBOYOriginal
2016-06-13 13:06:301057browse

Parse error: syntax error, unexpected T_VARIABLE on line 9
请问这个问题是怎么回事?我的代码如下:

echo $_POST['username'];
echo $_POST['password'];
echo $_POST['mailbox'];
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "11234";
$mysql_database = "user_information";
$sql ="INSERT INTO 'user_information'.'user_information_library'('user_name','password','mailbox')VALUES("$_POST['username']","$_POST['password']","$_POST['mailbox']")";
mysql_select_db($mysql_database,$con);
$con = mysql_connect($mysql_server_name,$mysql_username,$mysql_password);
$result = mysql_query($sql);
$id = mysql_insert_id();
mysql_close($con);
?>

------解决方案--------------------
$sql ="INSERT INTO user_information.user_information_library(`user_name`,`password`,`mailbox`) VALUES('{$_POST['username']}','{$_POST['password']}','{$_POST['mailbox']}')";

------解决方案--------------------
php 约定的关联数组元素的写法:
独立的
$var['key'] 只检查数组 $var 中是否有键 key
$var[key] 先检查是否有常量 key 定义,在检查数组 $var 中是否有键 key
双引号中
"$var['key']" 出错
"$var[key]" 只检查数组 $var 中是否有键 key
"{$var['key']}" 只检查数组 $var 中是否有键 key
"{$var[key]}" 先检查是否有常量 key 定义,在检查数组 $var 中是否有键 key



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article: PHPRPC for Java引见 Next article: CI 往 index.php