PHP und MFC - Kommunikationsfehler?



  • Hallo Zusammen

    Ich versuche über das Internet eine PHP-Datei auszuführen und das Ergebnis in eine Variable "s" zu speichern. Das klappt sehr gut.

    Jetzt will ich aber prüfen ob s == YES oder NO ist (Ausgabe von PHP ist entweder NO oder YES -> siehe http://scvserv.homedns.org/scvwt/check_updatestatus.php).

    Das mache ich mit if(s=='YES') { //Hier Etwas machen .. usw.

    Jedoch klappt es nicht! Die gesamte IF/ELSE Funktion wird ignoiert. Schreibe ich aber einfach zu unterst, OHNE IF/ELSE eine Messagebox mit der S-Variable drin, dann steht da immer das KORREKTE Resultat, entweder NO oder YES. Also ist s somit korrekt, aber warum werden die if's ignoiert???

    Hier der Code:

    CString somecode, s;      
         CInternetSession session("CheckForUpdates",1,INTERNET_OPEN_TYPE_PRECONFIG);
    
         CStdioFile* pFile = NULL;   
    	 CString strUrl("http://scvserv.homedns.org/scvwt/check_updatestatus.php");
    
       try  
       {  
               pFile = session.OpenURL(strUrl,1,INTERNET_FLAG_TRANSFER_BINARY,NULL,0);
    
            if(pFile)  
            {           
                while (pFile->ReadString(somecode) != NULL)  
                {  
                    s = s + somecode;  
                }  
                pFile->Close();  
            }       
       }  
       catch (CInternetException* e)  
       {        
            e->Delete();
            session.Close();
            CloseHandle(session);  
       }
    
      //s.Delete(0,1);
    
       if (s == "YES") //Wird ignoiert!
       {
       MessageBox("eins", "S-Wert", MB_OK);
       }
       if(s == "NO") //Wird Ignoiert!
       {
    	   MessageBox("null", "S-Wert", MB_OK);
       }
       MessageBox(s, "S-Wert Prüfen", MB_OK); //Gibt aktuell momentan den richtigen WErt YES zurück. Auch wenn ich dann die SQL DB ändere , wird danach NO ausgegeben. Alles korrekt.
    
    	return TRUE;  // return TRUE unless you set the focus to a control
    	// EXCEPTION: OCX Property Pages should return FALSE
    

    Gruss
    Wolf



  • Wegen den Leerzeichen die nach dem YES noch kommen.



  • Hallo,

    sind hinter der PHP-Ausgabe von YES noch Leerzeichen?

    Gruß
    foo



  • Ui ja.. da sind doch paar!

    Danke. 🙂 Hab es nun mit s.TrimRight(); gelöst.
    Nun klappts...

    Gruss
    Wolf


Anmelden zum Antworten