Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 461793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:00:37+00:00 2026-05-12T23:00:37+00:00

HI Guys, I have following problem. I’m trying to connect from my Iphone app

  • 0

HI Guys,

I have following problem. I’m trying to connect from my Iphone app to a php site, to access the mySql db, to get the right information.

This is my code:

    <?php
    mysql_connect ("localhost", "user", "pass") or die (mysql_error());
    echo "Connected to MySql <br /><hr />"; 
    mysql_select_db ("database_com") or die (mysql_error());
    echo "Connectted to Database <br /><hr />";

    $country = $_POST['country'];// THIS IS THE VALUE I WANT TO LOAD INTO THE SELECT STATEMENT
    echo "value <br /><hr />" . $country;

    $query = "SELECT * FROM world WHERE land='$country'";
    $result = mysql_query($query) or die (mysql_error());
    while ($row = mysql_fetch_array($result)) {
        $1 =    $row['1'];
        $2 =    $row['2'];
        $3 =    $row['a3'];
        $4 =    $row['4'];



        $xmltext = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<country></country>";
        $xmlobj = simplexml_load_string($xmltext);


        $xmlobj->addChild("1", $1);
        $xmlobj->addChild("2", $2);
        $xmlobj->addChild("a3", $a3);
        $xmlobj->addChild("4", $4);
        print header("Content-type: text/plain") . $xmlobj->asXML(); // Place future code ABOVE this line

        $xml->save(statistic.xml);

      }
    ?>

If I hardcode the value of land = “Germany” i get an answer, but if I do the other thing, nothing comes out of it.

I hope u can help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:00:37+00:00Added an answer on May 12, 2026 at 11:00 pm

    Do you have a form that posts a country to your php page? If so, is the form using method=”post”? If you are sticking the country in the url, use $_GET instead of $_POST.

    Also, call mysql_real_escape_string($_POST[‘country’]) to avoid SQL injection issues (like someone deleting all your databases).

    Also, this line:

    print header("Content-type: text/plain") . $xmlobj->asXML();
    

    has a number of issues. It should be:

    header("Content-type: text/plain");
    print $xmlobj->asXML();
    

    However, you cannot send headers after printing other stuff out – like your echo calls early in the script. It doesn’t sound like this is a problem yet, but it will be when your query works.

    Also, you’re looping through the result set. If you expect only one result, ditch the while loop. If you have more than one result, you will get errors because of the header() call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem with MySQL 5.5.24 and PHP 5.4.3. I have the following
Hei guys, I have the following problem: As I can see those arrows are
Guys, please help me with the following problem. I have encountered the famous cannot
Hello guys I have the following problem: INPUT : 2 ababaa aa OUTPUT :
Hi guys I have problem with xml parsing i have following xml which have
Hey guys, i have the following problem: 1 process executes a very large query
Hey guys I have the following sample. I have navigation which is loaded from
Hi guys I have the following query and I trying to write it in
So im having a problem (obviously). I have the following MySQL table data 7
Guys I have the following structure in my project. application/ Bootstrap.php configs/ application.ini modules/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.