以下代码出现 parse error:
<?php echo 'db.php'; //定义连接参数 var $mysql_server_address = 'sfdhfgdghj3.my3w.com'; var $mysql_database_login_name = 'bdvs443fgd4343'; var $mysql_database_password = '48sfbb76bfysdfg'; var $mysql_database_name = 'bdvs443fgd4343_db'; //连接数据库 $conn = mysql_connect($mysql_server_address, $mysql_database_login_name, $mysql_database_password); if(!$conn) { die('数据库连接处问题'.mysql_error()); } //使用数据库 $db_selected = mysql_select_db($mysql_database_name, $conn); if(!$db_selected) { die('连接bdm297464343_db出问题'.mysql_error()); } //sql语句 $sql = "insert into tt_user_roles (userrole) valuse('农民')"; if(mysql_query($sql, $conn)) { echo '角色数据已经插入表'; } else{ echo '角色数据插入失败'.mysql_error(); } mysql_close($conn); ?>
错误原因:
修改后的代码如下:
立即学习“PHP免费学习笔记(深入)”;
<?php echo 'DB.php'; $mysql_server_address = 'sfdhfgdghj3.my3w.com'; $mysql_database_login_name = 'bdvs443fgd4343'; $mysql_database_password = '48sfbb76bfysdfg'; $mysql_database_name = 'bdvs443fgd4343_db'; $conn = mysqli_connect($mysql_server_address, $mysql_database_login_name, $mysql_database_password); if(!$conn) { die('数据库连接处问题'.mysqli_error($conn)); } $db_selected = mysqli_select_db($conn, $mysql_database_name); if(!$db_selected) { die('连接bdm297464343_db出问题'.mysqli_error($conn)); } $sql = "insert into tt_user_roles (userRole) valuse('农民')"; if(mysqli_query($conn, $sql)) { echo '角色数据已经插入表'; } else{ echo '角色数据插入失败'.mysqli_error($conn); } mysqli_close($conn); ?>