开发者

trying to get the user details from mysql database got an error

开发者 https://www.devze.com 2023-03-27 23:04 出处:网络
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 ASNickname,\";

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";
0

精彩评论

暂无评论...
验证码 换一张
取 消