Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By gimbal2

Thread: [SOLVED] PHP Script to Java transmission trouble

  1. #1
    Minchan is offline Member
    Join Date
    Jan 2014
    Posts
    4
    Rep Power
    0

    Default [SOLVED] PHP Script to Java transmission trouble

    Good Day,

    I came up with a solution to send variables to my PHP Script (on some server) and receive back the echo. Everything is working just fine, no problems sending the information and receiving the echo content-wise. However, when I try to compare the received data to something else be it a string or integer it won't pass even though it is exactly identical. Here are some snippets:

    How I get my data:
    Java Code:
    BufferedReader inputS = null;
    	        try {
    	            String line;
    	            inputS = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    	            while ((line = inputS.readLine()) != null) {
    	                result += line;
    	            }
    	        } finally {
    	            if (inputS != null) {
    	                inputS.close();
    	            }
    	        }
    The function within this class returns the result, which I try to compare like this:
    Java Code:
    System.out.println("Compare #" + serverPW + "#" + " to #" + "1" + '#');
    if (serverPW == "1") [...]
    That println is only there to check my values, don't worry about that. But it tells me, that there are no white spaces and the variables I am about to compare are the exact same. I tried every plausible file type and values (not just integers, not just text) even though this one is a number treated as a string. I also tried replacing it with yet another variable but it is the exact same issue.

    Any ideas what could be wrong here?

    Thanks in advance
    Last edited by Minchan; 01-27-2014 at 04:58 PM.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,669
    Rep Power
    5

    Default Re: PHP Script to Java transmission trouble

    Java Code:
    serverPW == "1"
    I am almost 100% positive that these are not the same two object instances. Use the equals() method.
    Minchan likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    Minchan is offline Member
    Join Date
    Jan 2014
    Posts
    4
    Rep Power
    0

    Default Re: PHP Script to Java transmission trouble

    Derp, thanks a lot it works!

Similar Threads

  1. Replies: 5
    Last Post: 05-24-2013, 07:11 AM
  2. Trouble with a Redirect Script - Looking for Assistance
    By jeremy.wilson in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 12-30-2009, 09:47 PM
  3. Java script
    By kirtichopra2003 in forum Advanced Java
    Replies: 1
    Last Post: 12-04-2009, 07:55 PM
  4. java script
    By satti in forum Web Frameworks
    Replies: 0
    Last Post: 06-09-2009, 08:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •