从数据库检索信息时发生Java Php连接错误

从数据库检索信息时发生Java Php连接错误,java,php,mysql,Java,Php,Mysql,我不熟悉使用PHP和Java。我正在制作一个Android应用程序,我遇到了一个SQL语法错误。。。 错误: 返回Java: 查看与MySQL服务器对应的手册 第1行“@mail.com”附近使用的正确语法的版本。你知道我该怎么解决吗 我认为这是php脚本的一个问题。我怎样才能解决这个问题。非常感谢您的帮助 // Login by email and password if access success setId() // Saved Email as stat

我不熟悉使用PHP和Java。我正在制作一个Android应用程序,我遇到了一个SQL语法错误。。。 错误:

返回Java:

查看与MySQL服务器对应的手册 第1行“@mail.com”附近使用的正确语法的版本。你知道我该怎么解决吗

我认为这是php脚本的一个问题。我怎样才能解决这个问题。非常感谢您的帮助

        // Login by email and password if access success setId()
        // Saved Email as static string "staticEmail" and used to get CustomerID from customer table
        // Get & set CustomerID to "string qr_id" if  email=".$email
        /* 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 '@mail.com' at line 1
        */



  <?php
    //connect to MySQL database
    mysql_connect("localhost","name","pass") or  die(mysql_error());
    mysql_select_db("tls_db");

      $output = array();    

      if (isset($_GET['email'])){       
        $email = $_GET['email'];
        $sql = mysql_query("select CustomerID from customer where email=".$email) or die(mysql_error());

      while($row=mysql_fetch_assoc($sql)){
            $output[] = $row;               
           }
        mysql_close();
        print(json_encode($output));    
       }
    ?>
//如果访问成功,则通过电子邮件和密码登录setId()
//将电子邮件保存为静态字符串“staticEmail”,用于从customer表中获取CustomerID
//如果email=“.$email”,则获取并将CustomerID设置为“字符串qr\U id”
/*错误:
您的SQL语法有错误;请检查与MySQL服务器对应的手册
第1行“@mail.com”附近使用的正确语法的版本
*/
爪哇:

private void setId(){
InputStream=null;
ArrayList nameValuePairs=新的ArrayList();
试一试{
HttpClient HttpClient=新的DefaultHttpClient();
HttpPost HttpPost=新的HttpPost(
“http://“+URL+”/tls_db/log.php?email=“+staticEmail);//发布电子邮件123@mail.com
setEntity(新的UrlEncodedFormEntity(nameValuePairs));
HttpResponse response=httpclient.execute(httppost);
HttpEntity=response.getEntity();
is=entity.getContent();
}捕获(例外e){
e(“Log_标记”,“http连接错误”+e.toString());
}
//将响应转换为字符串
试一试{
BufferedReader reader=新的BufferedReader(新的InputStreamReader(
is,“iso-8859-1”),8);
sb=新的StringBuilder();
sb.append(reader.readLine()+“\n”);
字符串行=”;
而((line=reader.readLine())!=null){
sb.追加(第+行“\n”);
}
结果=sb.toString();
is.close();
}捕获(例外e){
Log.e(“Log_标记”,“错误转换结果”+e.toString());
}
试一试{
JSONArray jArray=新JSONArray(结果);
for(int i=0;i
您需要在SQL查询中引用$email:

 $sql = mysql_query("select CustomerID from customer where email='".$email."'") or die(mysql_error());

顺便说一句,您的代码容易受到SQL注入的攻击。请务必阅读如何防止此攻击向量。

您需要在SQL查询中引用$email:

 $sql = mysql_query("select CustomerID from customer where email='".$email."'") or die(mysql_error());

顺便说一句,您的代码容易受到SQL注入的攻击。请务必阅读如何防止此攻击向量。

您需要在SQL查询中引用$email:

 $sql = mysql_query("select CustomerID from customer where email='".$email."'") or die(mysql_error());

顺便说一句,您的代码容易受到SQL注入的攻击。请务必阅读如何防止此攻击向量。

您需要在SQL查询中引用$email:

 $sql = mysql_query("select CustomerID from customer where email='".$email."'") or die(mysql_error());
顺便说一句,您的代码容易受到SQL注入的攻击。请务必阅读如何防止这种攻击