Parse error: syntax error, unexpected T_VARIABLE on line 九
程序员文章站
2022-05-31 16:01:25
...
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
相关文章
相关视频
推荐阅读
-
PHP错误Parse error: syntax error, unexpected end of file in test.php on line 12解决方法
-
PHP Parse Error: syntax error, unexpected $end 错误的解决办法
-
PHP异常Parse error: syntax error, unexpected T_VAR错误解决方法
-
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting 异常怎么解决
-
PHP解析错误 PHP Parse error: syntax error, unexpected '[' in
-
Parse Error: syntax error, unexpected $end 错误_PHP教程
-
PHP异常Parse error: syntax error, unexpected错误解决方法
-
Parse error: syntax error, unexpected T_STRING in C:AppServwww1.php on line 三
-
Parse Error: syntax error, unexpected $end 错误
-
Parse error: syntax error, unexpected T_FUNCTION, expecting ')'该如何解决