Nav Link On

iPhone Dev Forums > General Development > SDK Coding Help > Send data to server

Reply

 

LinkBack Thread Tools Display Modes
Old 10-22-2008, 04:15 PM   #1 (permalink)
Junior Member
Default Avatar
 
Join Date: Oct 2008
Posts: 4
Question Send data to server

Hi, I'm starting developing for the iPhone platform and I have a difficult task to do:

I have to find the way to send images from iPhone to a MySQL database in a server in the Internet.
The server side code is written whit PHP and iPhone platform does not have support for PHP neither for MySQL.

My question is:
If the only way to send data is by web services,

Which services are those?
Is it an option to use XML parsing?
Where should I start to look for the solution?

Thanks for your help.
carlosl3g is offline   Reply With Quote
Old 10-23-2008, 07:27 AM   #2 (permalink)
Member
Default Avatar
 
Join Date: Oct 2008
Posts: 31
Default

Hi,
Yea you should use XMLs to send data for sure, and you should use XML parsing if you have to receive some data from server.
You don't have MySQL on iPhone but you do have SQLight, you can read documentation for "sqlite3" or in the framework for iPhone i think it's called "libsqlite3.0.dylib".
And for connecting via web use NSURL there is plenty explained in the documentation about this.
Sergiu.
sergiu.burlacu is offline   Reply With Quote
Old 10-23-2008, 05:07 PM   #3 (permalink)
Junior Member
Default Avatar
 
Join Date: Oct 2008
Posts: 3
Default

It doesn't matter what language the server-side stuff is in. It doesn't matter that there's no PHP on the iPhone. You're not going to do anything with PHP on the iPhone.

It doesn't matter that there's no MySQL on the iPhone. Your database stuff is done on the server. You won't be doing any MySQL stuff on the iPhone.

You don't necessarily have to use XML to send the data. One way to send it would be to put it in the URL and use NSURL to create the URL and [NSString stringWithContentsOfURL] to send it and get a response. You'd hex-encode the data and send something like: "http://www.myserver.com/myreceiver.php?data=4F1AB736289EDC..."

Your myreceiver.php would just look at the value of the data parameter, convert it to binary and store it in the database.

Look at NSURL and NSURLConnection.

Craig
craig is offline   Reply With Quote
Old 10-24-2008, 02:13 PM   #4 (permalink)
Member
Default Avatar
 
Join Date: Aug 2008
Location: main(int argc, void **argp)
Posts: 74
Send a message via AIM to A_Nub Send a message via MSN to A_Nub
Default

or you could go more advanced and use POST rather than GET. Or you could have a simple socket server in php and directly send the data from your iPhone.
__________________
Quote:
Originally Posted by Xfacter
Amirite? I knew iwasrite.
A_Nub is offline   Reply With Quote
Old 10-24-2008, 02:49 PM   #5 (permalink)
Junior Member
Default Avatar
 
Join Date: Oct 2008
Posts: 4
Cool Thanks for your advice

Yep, I think that's a good idea, there are a class called NSData wich I can use for "encapsulate" the data.

- (NSData *)compress: (NSData *)data // IN
{
if (!data || [data length] == 0)
return nil;

// zlib compress doc says destSize must be 1% + 12 bytes greater than source.
uLong destSize = [data length] * 1.001 + 12;
NSMutableData *destData = [NSMutableData dataWithLength:destSize];

int error = compress([destData mutableBytes],
&destSize,
[data bytes],
[data length]);
if (error != Z_OK) {
LOG(0, ("%s: self:0x%p, zlib error on compress:%d\n",
__func__, self, error));
return nil;
}

[destData setLength:destSize];
return destData;
}

I've been trying to use this function but along with that I have other problems with the compiler, it says:

warning: implicit declaration of function 'LOG'

The same warning is also for functions 'NSAsert' and 'compress'

I have definitions like:

#define ASSERT(x) NSAsert(x, @"")
#define Log(x,y)

Maybe is just that some function that I use are not available for iPhone development or I need a library call.
__________________
Chl3g
carlosl3g is offline   Reply With Quote
Reply

iPhone Dev Forums > General Development > SDK Coding Help


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

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


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