作者:郭爷们1986_488 | 来源:互联网 | 2023-05-19 04:43
GoalIamwritingaprogramwhereausersinputistakenasaparameterandqueriedagainstanonl
Goal
I am writing a program where a user's input is taken as a parameter and queried against an online API.
我正在编写一个程序,其中将用户的输入作为参数并查询在线API。
Problem
Oddly, I cannot get my parameter into my API successfully. The error I get is "Could not look up user information; You have an error in your SQL syntax;" Which as it says plainly , is an SQL error. Therefore I was thinking there was a problem in passing my parameter since the application works when I hard code parameter and say "select name from table where id=1"
.
奇怪的是,我无法成功地将我的参数存入我的API。我得到的错误是“无法查找用户信息;您的SQL语法中有错误;”正如它所说的那样,是一个SQL错误。因此我认为传递我的参数存在问题,因为当我硬编码参数并且说“从表中选择ID = 1”时,应用程序正常工作。
This is the parameter code and despite many edits and changes I got the same issue which caused me to look to my php even if everything works right in the browser.
这是参数代码,尽管进行了许多编辑和更改,但我得到了同样的问题,这导致我查看我的php,即使一切正常在浏览器中。
HttpParams param = new BasicHttpParams();
ArrayList inputArguments = new ArrayList();
inputArguments.add(new BasicNameValuePair("id", idnum));
HttpClient client = new DefaultHttpClient(param);
HttpPost request = new HttpPost("http://myurl.com/DAIIS/getName.php");
request.setHeader("Content-Type", "application/x-www-form-urlencoded");
request.setEntity(new UrlEncodedFormEntity(inputArguments, "UTF-8"));
HttpResponse httpRespOnse= (HttpResponse) client.execute(request);
Where I think the problem lie
在哪里我认为问题在于
I belives the problem lies in my select statement
我认为问题在于我的选择陈述
I say this because after stripping my API to the bare minimum the program's error was Could not look up user information; 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 '' at line 1
but if i hard code the parameter (it works) or put something random like stu_id=$_GET['id'];
it returns blank.
我这样说是因为在将我的API剥离到最低限度之后程序的错误是无法查找用户信息;您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以便在第1行的''附近使用正确的语法,但是如果我硬编码参数(它可以工作)或者像stu_id = $ _ GET ['id']那样随意添加一些东西;它返回空白。
So is the way that I used this parameter incorrect for android? even if it works in the browser?
那么我使用这个参数的方式对于android来说是不正确的?即使它在浏览器中有效?
Thank you
1 个解决方案