2

I have this code on php document

<?php echo '<script type="text/javascript">
        document.write( geoip_city() );
      </script>' ?>

after open in browser it returns your city name but on

WebClient client = new WebClient();

            string client2 = client.DownloadString("http://www.mywebsite/ip2.php");

            MessageBox.Show(client2);

it returns the source code. Why does this happen?

I am using this script for geolocation.

6
  • 1
    Perhaps your server is not setup to parse PHP? Try creating a single script that looks like this: "<? phpinfo(); ?>" and open it on your browser. If it shows a long list of information about your PHP setup, then this isn't the issue. If it just shows "<? phpinfo(); ?>" in the browser, then your web server isn't interpreting, and it'd be a web server configuration issue. Commented Jul 28, 2013 at 17:54
  • You need to download the file from the live server. If it is hosted on the same computer, you need to use client.DownloadString("127.0.0.1/mydocument/ip2.php"); Make sure you have PHP setup properly too. Commented Jul 28, 2013 at 18:06
  • the file is on server with php and code work but in c# after download string return only source code Commented Jul 28, 2013 at 18:55
  • WebClient does not runs javascript code see: stackoverflow.com/questions/5372277/webclient-runs-javascript Commented Jul 29, 2013 at 13:59
  • i have tested with webbrowser. webbrowser.navigate("http//www.mysite/ip2.php") string city = webbrowser.Documenttext.Tostring(); retunr always all source code same the webclient Commented Jul 29, 2013 at 22:19

1 Answer 1

0

It sounds like you do not have PHP set up correctly on the server.

When you go to the page ( http://www.mywebsite/ip2.php ) does the source code show up there as well? What server software are you running?

Sign up to request clarification or add additional context in comments.

1 Comment

php5 and mysql... on browser the site work, only in c# have problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.