【发布时间】:2015-01-23 19:20:49
【问题描述】:
我来了
解析错误:语法错误,/home/rainlikq/public_html/script/signupt.php 第 17 行用户名语句中出现意外的“$username”(T_VARIABLE)......
谁能给我一个解决方案
我将其用于注册目的... 我正在尝试执行它...... 实际上我正在将 json 数据解析到 android 设备...
<?php
$host="localhost"; //replace with database hostname
$username="rainlikq_rahul"; //replace with database username
$password="rahul1"; //replace with database password
$db_name="rainlikq_rainforest"; //replace with database name
$con=mysql_connect($host, $username, $password)or die("cannot connect");
mysql_select_db($db_name)or die("cannot select DB");
if(isset($_POST['name'], $_POST['password'], $_POST['password2'], $_POST['username'], $_POST['mobile']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$name = $_POST['name'];
$mobile = $_POST['mobile'];
$result = mysql_query("insert into user(user_email,user_password,name,mobile) values( '$username','$password','$name','$mobile')");
// array for JSON response
$response = array();
if ($result) {
// successfully inserted into database
$response["success"] = 1;
$response["message"] = "Signed up successfully";
// echoing JSON response
echo json_encode($response);
} else
{
// failed to insert row
$response["success"] = 0;
$response["message"] = "Oops! An error occurred.";
// echoing JSON response
echo json_encode($response);
}
}
else
{
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>
【问题讨论】:
-
您在第 15 行缺少一些关闭
)- 让您更加努力地找出它们在哪里.. -
如果有很多条件,如果我将它们分开。一行中的每个或最多两个条件。这样做对我的编程生涯有很大帮助。
-
根据您的编辑;那是您的完整和实际代码吗?另外,你在用这个吗? JS?阿贾克斯?包括?
-
此代码不会产生该错误。 - 反正不是你发布的编辑。