Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: HTTP Error with a PHP Get String  (Read 2822 times)

0 Members and 1 Guest are viewing this topic.

Ninjasturm

  • Newbie
  • *
  • Posts: 16
    • View Profile
HTTP Error with a PHP Get String
« on: October 19, 2010, 05:06:10 pm »
Hello Community,

i try to connect to a webpage with sf::Http.

First the webpage Init.php
Code: [Select]

<?php 
$mysql_host  $_GET['Server'&#93;;
$mysql_user  $_GET['Username'&#93;;
$mysql_pass  $_GET['Password'&#93;;
$mysql_db $_GET['Database'&#93;;
@mysql_connect&#40;$mysql_host, $mysql_user, $mysql_pass&#41; OR
die &#40;"Error&#58; MySQL failed"&#41;;
@mysql_select_db&#40;$mysql_db&#41; OR
die &#40;"Error&#58; MySQL failed"&#41;;
echo &#40;"Success"&#41;;
?>



Then the code in my app
Code: [Select]

            sf::Http Http;
            FullPHPAddress = "localhost";
            FullPHPAddress = FullPHPAddress + "\\Init.php?Server=";
            FullPHPAddress = FullPHPAddress + myMySQLAddress.ToString();
            FullPHPAddress = FullPHPAddress + "&Username=";
            FullPHPAddress = FullPHPAddress + myMySQLUsername;
            FullPHPAddress = FullPHPAddress + "&Password=";
            FullPHPAddress = FullPHPAddress + myMySQLPassword;
            FullPHPAddress = FullPHPAddress + "&Database=Database";
            Http.SetHost(FullPHPAddress);
            sf::Http::Request Request;
            Request.SetMethod(sf::Http::Request::Get);
            Request.SetURI("/");
            Request.SetBody("");
            Request.SetHttpVersion(1, 0);
            Request.SetField("From", "ipod.leon@googlemail.com");
            sf::Http::Response Page = Http.SendRequest(Request);
            if (Page.GetStatus() != 200)
            {
                StartErrorIndex += 1;
                StartErrorIndex[StartErrorIndexState] = "Error: PHP failed!\n";
                SystemOK = false;
            }
            if (Page.GetBody() == "Error: MySQL failed")
            {
                StartErrorIndex += 1;
                StartErrorIndex[StartErrorIndexState] = "Error: MySQL failed!\n";
                SystemOK = false;
            }


When i call up the error index i get the PHp failed error!
please can anybody help me. Maybe is there an error in the get string.

Thanks for help!

Randati

  • Guest
HTTP Error with a PHP Get String
« Reply #1 on: October 19, 2010, 05:44:01 pm »
Http.SetHost() requests only the host name (e.g. "www.google.com"). The rest of the address is set using Request.SetURI().
Code: [Select]
Http.SetHost("localhost");
FullPHPAddress = "/Init.php?Server=";
...
Request.SetURI(FullPHPAddress);

Notice the forward slash instead of a backslash.

Ninjasturm

  • Newbie
  • *
  • Posts: 16
    • View Profile
HTTP Error with a PHP Get String
« Reply #2 on: October 19, 2010, 06:39:19 pm »
Thanks now it works fine.