Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4android > Basic4android Getting started & Tutorials
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Basic4android Getting started & Tutorials Android development starts here. Please do not post questions in this sub-forum.

Connect Android to MySQL Database Tutorial

Reply
 
LinkBack Thread Tools Display Modes
  #21 (permalink)  
Old 05-08-2011, 08:19 AM
Junior Member
 
Join Date: May 2011
Posts: 35
Default Don't get this working

I have a MYSQL Database where I like to get some info from.
When I copy the php source to the webroot and connect with the app.
Then I get in the LogCat the source of the php file.
I have a connection to the database when I debug the php Script.
What i'm doing wrong here
Server is Xampp.

Last edited by swissmade : 05-08-2011 at 08:22 AM.
Reply With Quote
  #22 (permalink)  
Old 05-08-2011, 08:38 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Your server should run the PHP script. For some reason it now treats it as a text file.
Reply With Quote
  #23 (permalink)  
Old 05-08-2011, 09:54 AM
Junior Member
 
Join Date: May 2011
Posts: 35
Default

Quote:
Originally Posted by Erel View Post
Your server should run the PHP script. For some reason it now treats it as a text file.
Erel,

Thanks again for your fast respond.
Found the error the Script started with <? and not with <?php

Reply With Quote
  #24 (permalink)  
Old 05-12-2011, 04:50 PM
Junior Member
 
Join Date: May 2011
Posts: 12
Default



maybe this question is not suitable

but I create DB and PHP file

this error is appear

Compiling code. Error
Error parsing program.
Error description: Unknown type: httpclient
Are you missing a library reference?
Occurred on line: 2
Dim hc As HttpClient

what is mistake??
I need to answer
Thanks
Reply With Quote
  #25 (permalink)  
Old 05-13-2011, 05:17 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You should add a reference to the Http library. It is done in the Libraries tab in the right pane. Note that it can only be done with the full version.
Reply With Quote
  #26 (permalink)  
Old 05-14-2011, 10:29 AM
Junior Member
 
Join Date: Apr 2011
Posts: 18
Default

Is there someone in this group who can change this part of php code in asp code

$query = file_get_contents("php://input");
$sth = mysql_query($query);

if (mysql_errno()) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysql_error();
}
else
{
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
}
Reply With Quote
  #27 (permalink)  
Old 05-16-2011, 10:25 AM
Junior Member
 
Join Date: May 2011
Posts: 12
Default

if I change the line 40 to

req.InitializePost2("C:\xampp\htdocs\countries.php ", query.GetBytes("UTF8"))

this error appears

An error has occured in sub: main excuteremotequery
(B4A line:40)
req.InitializePost2("C:\xampp\htdocs\countries.php " , query.GetBytes("UTF8"))
java.lang
IllegalArgumentException:
Illegal character in schemeSpecificPart at index 2:
C:\xampp\htdocs\countries.php

Thanks a lot
Reply With Quote
  #28 (permalink)  
Old 05-16-2011, 05:17 PM
Junior Member
 
Join Date: May 2011
Posts: 12
Default

I edit php file to this

$databasehost = "localhost";
$databasename = "android";
$databaseusername ="root";
$databasepassword = "1234";

the type of ID is VARCHAR (5)
population is INT (5)
name VARCHAR (20)


Last edited by Reemj : 05-16-2011 at 05:21 PM.
Reply With Quote
  #29 (permalink)  
Old 05-17-2011, 08:02 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

The PHP script should be located in a server that can execute the script. It cannot be accessed as a regular file.
Reply With Quote
  #30 (permalink)  
Old 05-17-2011, 03:42 PM
Junior Member
 
Join Date: May 2011
Posts: 12
Default thank you

thank you ,

I changed the link to this http://localhost/countries.php

and change type of populaion from VARCHAR to text



another problem appears,

in java.lang.exception: sub
hc_responceerror signture dose not match expected signuter.
continued?





tahnks for the help

Last edited by Reemj : 05-17-2011 at 03:46 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Android JSON Tutorial klaus German Tutorials 0 02-11-2011 10:31 PM
Android Serial Tutorial klaus German Tutorials 0 01-26-2011 09:05 PM
connect to mysql server from device encolo Questions (Windows Mobile) 5 08-30-2010 04:50 PM
How To Connect Basic 4ppc With Mysql ? jothis Questions (Windows Mobile) 2 05-18-2010 09:50 PM
connect or sync database in PPC from Desktop kalmenchia Questions (Windows Mobile) 1 01-09-2010 08:41 AM


All times are GMT. The time now is 10:35 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0