I am trying to get the user details form mysql database by using the below query
$rows=array();
$query = "SELECT CONCAT(usrFirstname,'',usrSurname) As FullName,usrNickname AS Nickname,";
$query.= "usrEmail As EmailAddress,usrGender AS Gender,DATE_FORMAT(usrDOB,'%d%m%y') As DOB,usrBelt AS BeltId";
$query.= "FROM user";
$result = mysql_query($query);
echo mysql_error();
if($result)
{
while($row=mysql_fetch_assoc($开发者_开发知识库result))
{
$rows[] = $row;
}
}
it was giving error like this
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user' at line 1
Try do add a space before from clause
$query.= " FROM user";
You have no space between usrBelt AS BeltId
and FROM
.
You're missing a space in front of the word FROM
.
$query.= "usrEmail As EmailAddress,usrGender AS Gender,DATE_FORMAT(usrDOB,'%d%m%y') As DOB,usrBelt AS BeltId";
$query.= " FROM user";
精彩评论