Parse error: syntax error, unexpected T_VARIABLE on line 九
程序员文章站
2024-01-04 18:44:40
...
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
请问这个问题是怎么回事?我的代码如下:
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
相关文章
相关视频
推荐阅读
-
Parse error: syntax error, unexpected T_VARIABLE on line 九
-
Parse error: syntax error, unexpected
-
PHP异常Parse error: syntax error, unexpected T_VAR错误
-
PHP错误Parse error: syntax error, unexpected end of file in_PHP
-
PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE
-
微信开发 - syntax error, unexpected T_AS in example.php on line 211?
-
Parse error: syntax error, unexpected T_DO, expecting '' in解决方案
-
Parse error: syntax error, unexpected T_DO, expecting ';' in
-
PHP错误Parse error: syntax error, unexpected end of file in test.php on line 12解决方法_php技巧
-
PHP Parse Error: syntax error, unexpected $end 错误的解决办