简体   繁体   中英

Connect DB MySql Android App

I dont know how to config them. I'm new dev.

This is error in Logcat

05-29 09:20:08.217: E/log_tag(1430): Error in http connection java.net.UnknownHostException: Unable to resolve host "myhostname.com": No address associated with hostname
05-29 09:20:08.217: E/log_tag(1430): Error converting result java.lang.NullPointerException
05-29 09:20:08.245: W/EGL_emulation(1430): eglSurfaceAttrib not implemented
05-29 09:20:08.257: D/OpenGLRenderer(1430): TextureCache::get: create texture(0xb7f752e0): name, size, mSize = 35, 61440, 1200228
05-29 09:20:08.257: E/log_tag(1430): Error parsing data org.json.JSONException: End of input at character 0 of

This is "MainActivity.java". I just change my host name.

           @Override
        protected Void doInBackground(String... params) {
          String url_select = "http://myhostname.com/ad/demo.php";

          HttpClient httpClient = new DefaultHttpClient();
          HttpPost httpPost = new HttpPost(url_select);

demo.php

<?php
mysql_connect("localhost","root","") or  die(mysql_error());
mysql_select_db("myDB");
$sql=mysql_query("select * from demo");
while($row=mysql_fetch_assoc($sql))
$output[]=$row;
print(json_encode($output));
mysql_close();
?>

I do From enter link description here

The app just can't find your url_select -Adress. Because myhostname.com doesn't exist. So it's impossible to connect to this adress. Try to use XAMPP . It generates an own server on your computer to which you can connect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM