Iphone - Insert Imagedata Into Database From XCode Using JSON?

Nov 29, 2010

How to insert/store images in MySQL database from XCode via PHP using JSON?


Iphone - Xcode Send Data From Text Input Through A Post Function?

Sep 19, 2010

Is it possible to send text from an xcode input and have the data sent through a php function?

View 2 Replies View Related

Iphone - Sending Http Request Using Method Post To A Mobile Application That Is Using Objective C (.xcode)

Mar 27, 2011

I am working on project that is taking the data from a voiceXML application and then the voiceXML application send the variable that contains the data into a .php and I am done with that part but the problem is when I want to send the variable by sending a HTTP POST Request from .php to the mobile application which is installed on the iphone that is written using objective C programming language with an extension (.xcode), I faced a problem in receiving the variable on the mobile application,

So what I tried to do for a couple of months is to send the variable first to another .php and if it works with me, I will try to fixed the problem with mobile application. I used httpRequest () Class - method post in order to send variable but the problem is that I don't know what to write on the other .php file to receive this variable and then display it. This is the whole code :


I used the database as a buffer since I am working on different sessions which is between the .VXML and first .php or the first .php and second .php The form.php contains the following which just display a white page and doesn't print the variable that is coming from the first .php:


So what I have to do in order to receive the variable correctly and display it in the second php?

View 1 Replies View Related

Iphone - Newline In Text - UITextView To Sqlite - Sqlite To JSON (via NSString) - JSON To It

May 11, 2011

I have a UITextView that ends up sending the text to a sqlite db on the iPhone. Later on I will be querying this data from sqlite, putting it into a JSON string and sending it to a server (PHP/MySQL) from the iPhone using ASIHTTPRequest (using ASIFormDataRequest class). There is a data condition where this send to PHP fails to decode properly (using json_decode). The data condition seems to be where there's a newline in the text that was entered to sqlite via the UITextView.

Things I've Tested: Write out the same JSON string that I'm trying to send to the server to a text file on the iPhone. Take that text, copy it into a web form (that I put together for this troubleshooting) that POSTs the data to the same PHP script that accepts the JSON from the iPhone. This processes successfully (e.g. decodes and writes to the MySQL db). Write out the same JSON string that I'm trying to send to the server to the console (using NSLog). Copy the text from the console and copy it into a web form that POSTs the data to the same PHP script that accepts the JSON from the iPhone. This processes successfully (e.g. decodes and writes to the MySQL db).

Remove the newline in the sqlite db, run the app and send the JSON to the server per design, no problem...it decodes and writes to the MySQL db. I want to keep the newline in the text as that is what the user typed and what they will expect when they see the information on the server. Not sure how to keep the newline and at the same time be able to send the data to the server without any issues.

View 1 Replies View Related


Mar 11, 2011

I'm looking to call a HTTP_POST from the iPhone SDK to a php file on my server. If I call this below:


Should I be able to receive this post data like so (in php):

echo "Hello";
echo $_POST['test'];


To test, in my connectionDidFinishLoading I'm simply logging the whole response
- (void)connectionDidFinishLoading:(NSURLConnection *)conn
NSString *responseString = [[NSString alloc] initWithData:dataRecieved encoding:NSASCIIStringEncoding];
[dataRecieved release];
NSLog(@"Response: %@", responseString);

I get the hello that I echoed before looking for the post, but nothing else. Does anyone know where I'm going wrong?

View 3 Replies View Related

Iphone - Garbage After JSON - Array - YQL

Oct 25, 2010

i'm using YQL to send data back to an iPhone app i'm developing. I've got a JSON parser on the iphone and a PHP page on my webhost. This is the PHP:

header('Content-type: application/json');
$arr = array();
$result = $_GET["q"];
$yql_base_url = "http://query.yahooapis.com/v1/public/yql";
$yql_query = "select * from search.web where query ='%s'"; //YQL query to retrieve search results
$value = "lindsay+lohan";

When i use my iphone app and attempt to retrieve it, it says "Json parse failed: Garbage after JSON" And if i run the PHP file in a browser, i see all the JSON data fine but after it there is "[1]", which is screwing it up i think?

View 1 Replies View Related

Iphone JSON-Framework EOF Error?

Apr 24, 2011

I'm attempting to use Json-Framework to parse output (on the iPhone) from my website. The data on the website is an array of news objects... passed through PHP's json_encode().The JSON Output is here:[URL]....I am able to conne to the server and store the JSON data, then I do:

NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

View 1 Replies View Related

Google/twitter Search From Iphone Using Json?

Oct 25, 2010

header('Content-type: application/json');
$json = file_get_contents("http://twitter.com/status/user_timeline/lindsaylohan.json?count=1");
$temp = json_decode($json);
$array = Array();
$array[] = $temp;
echo json_encode($array);

I have a JSON parser in my iphone app. I'm using the above PHP code to try and search Twitter. Can anyone tell me the best way to search the web or get twitter results and return them to my app? I've tried YQL but could not get on with it. All i want is raw text returned to my app. Almost like RSS feeds

View 1 Replies View Related

JSON Encoding - Get MySQL Data To An IPhone?

Jun 2, 2011

Im new to JSON and have whats probably a basic question. I have some MySQL rows I want grab with Php, and then JSON encode for a response to an iphone request.

1) Whats the format for the array to encode this info?

2) Where the does the response code (200) fit into it?

View 2 Replies View Related

Get Json Data From Iphone Post Request?

Sep 7, 2010

I am developing an iPhone App using JSON framework, I am calling a PHP script to update MySQL database on local server. Using these code:

NSString *jsonString = [sendData JSONRepresentation];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString*post = [NSString stringWithFormat:@"&json=%@", jsonString];
NSData*postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO];
[request setURL:[NSURL URLWithString:@"http://localhost:8888/update.php"]];

I would like to ask: What is the PHP script to get data from that request, and how I can decode JSON data to PHP object to update to database?

View 3 Replies View Related

Iphone - JSON Return String Options?

Sep 15, 2009

I don't know any PHP so another developer helped me out with this code. I am trying to return the names of all the files in a folder on my server. These are then passed to my iPhone app which uses the data. However, I have 160 files in the folder and the JSON string only returns 85. Is there something wrong with this code:

$path = 'Accepted/';

View 2 Replies View Related

Send An Array Of Object From IPhone App To A Script With JSON?

Jan 4, 2010

I have an iPhone app with an array of objects that I want to send to a PHP script and have them be stored in a mySQL database. The objects in the array contain only floating points and strings, nothing special.

From what I understand the best way to send the array to the php script is to convert the array into an JSON, send it to the php script via http post, and do a json_decode on the other end. However I'm having a hard time figuring out how to convert the array into a json object.

View 3 Replies View Related

IPhone App/JSON - Posting Data To Remote Database?

Jul 6, 2011

I have an iPhone app that uses ASIHTTPRequest to post data to a php file, which then uses sql to update the database accordingly.What's bugging me is I keep reading that I should encode my posted data in JSON format. Can somebody explain to me the point in this? Why should I encode in JSON format? What are the benefits, needs for this..


View 2 Replies View Related

IPhone - Send JSON Object To Server In POST?

Apr 9, 2011

I would like to send my contact list with all numbers for each numbers. I'm trying to send a JSON Object (with all my data) to a PHP file and to decode with the json_decode function. Is it possible to use JSON to send to a server by POST in HTTPrequest

View 3 Replies View Related

MySql Table Returning JSON That Needs Formatting For IPhone UITableview

Jun 12, 2010

I have a php query the returns the following JSON format from a table.


View 1 Replies View Related

Objective C - More Specific About Sending Json With Utf8 To Iphone From Server?

Jun 30, 2011

We have php server that sends json string in utf-8 encoding. Im responsible for the iphone app that get the data. I want to be sure that on my side everything is correct :

//after I downlad the data stream :
NSString* content = [[NSString alloc] initWithData:self.m_dataToParse encoding:NSUTF8StringEncoding];
//here the data is shown correctly in the console
SBJsonParser *_parser = [[SBJsonParser alloc]init];
NSDictionary *jsonContentDictionary = [_parser objectWithData:self.m_dataToParse];
//here, when i printer values of array IN array, i see u454 u545 4545 format. any ideas why ?

im using the latest version of json library : [URL] There is problem is the iphone side? (json parser? ) or in the php server?

just to be clear again :
1.on the console, before json, the string looks o.k
2.after doing json, the array in array values are in the format of u545 u453 u545

View 1 Replies View Related

Get Imagedata As Binary String?

Jul 30, 2009

I'm using a solution for assembling image files to a zip and streaming it to browser/Flex application.(ZipStream by Paul Duncan, [URL]

Just loading the image files and compressing them works fine. Here's the core for compressing a file:

// Reading the file and converting to string data
$stringdata = file_get_contents($imagefile);
// Compressing the string data
$zdata = gzdeflate($stringdata );


View 1 Replies View Related

Write The Server Side If Using The Json On Client Side Of The Iphone?

May 7, 2010

i want to make my server side in php. after writing the code in php can i directly use json to parse it of or something other required on the server side with php.can you give me some example of it, how to do this on server side if i want to use json of my client side.

View 3 Replies View Related

Print Imagedata From String Variable

Jul 17, 2005

I got a windows com executable which returns a jpg image in a BSTR.

Let's say, the var that holds the data is $imgData.

With perl, in a cgi script, I may simpy write:
$| = 1;
print "Content-type: image/jpeg

print $imgData;
and the Image is propperly printed to the Client-Browser.

Now I want to achieve the same with php, but I just can't find a way to
treat the data as binary instead of a formated string.
As far as I know, echo $imgData shouldn't expect a formated string, as print

(I know, returning a Safearray from the com executable would be a better way
and probably I will also do it that way, but at the moment, I'm trying to
solve this problem.)

View 7 Replies View Related

PHP And Xcode?

Jul 17, 2005

Does anyone know of a way to make Apple's Xcode editor do syntax
highlighting and tooltips for PHP functions? I found some hacks for the old
Project Builder, but they don't seem to work with Xcode.

View 1 Replies View Related

Iphone SDK - Upload Image From Iphone To A Server Send Empty File?

Oct 21, 2010

I try to send a photo and GPS location to server via PHP here is the PHP part:Copy from here Saving the Uploaded File The examples above create a temporary copy of the uploaded files in the PHP temp folder on the server. The temporary copied files disappears when the script ends. To store the uploaded file we need to copy it to a different location:

if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
if ($_FILES["file"]["error"] > 0)


The script above checks if the file already exists, if it does not, it copies the file to the specified folder.

Note: This example saves the file to a new folder called "upload"

now back to iOS part ,I only can send GPS location to server ,it's easy because just a string. and you can download sample code here But an image is not,I do some search and found this discussion I directly put the code in my send GPS&image button the best thing is it can feedback I send the file success or failed

this is the most message I got after I send photo to server

1.Invalid file

2.Return Code: Upload: Type: Size: 0 KbTemp file: Stored in: upload/

I follow some guide to save image to NSData

NSData *photoData= UIImageJPEGRepresentation(self.theimageView.image, 1.0);

and I also check there is data inside or not so simply add this code into Button action

if (photoData == nil) {
NSLog(@"The photo is nothing !!!");
else {
NSLog(@"Photo inside !!!!");

But How To Upload An Image To Server ??? maybe I need to give a file name then upload it ???but how to...

I never use camera function and upload data before Hope someone can figure out this problem

View 4 Replies View Related

Creating A Login System Using Xcode?

Jan 16, 2011

im trying to create a iphone app using xcode, and i wanted to know i can authenticate users remotely using https i.e

user enters thier username and password send the varibales to a php file and gets the reuslts back!!

i know how to sort everything out in terms of php, but in the xcode side im really stuck!!

p.s. is thier a class out thier or tutorial i can use to guide me.

View 1 Replies View Related

Decode Some Json And Insert The Values In Db?

Nov 22, 2010

I'm trying to decode some json and insert the values in mysql . below is my code :

$json = '
{"d":[{"Id":1059,"Name":"Alfa Romeo - 145"},{"Id":20020,"Name":"Alfa Romeo - 146"},{"Id":1060,"Name":"Alfa Romeo - 147"},{"Id":20021,"Name":"Alfa Romeo - 155"},{"Id":1061,"Name":"Alfa Romeo - 156"},{"Id":20022,"Name":"Alfa Romeo - 159"},{"Id":20023,"Name":"Alfa Romeo - 164"},{"Id":20024,"Name":"Alfa Romeo - 166"},{"Id":20025,"Name":"Alfa Romeo - 33"},{"Id":20026,"Name":"Alfa Romeo - Brera"},


The error that I get is

Fatal error: Cannot use object of type stdClass as array in C:wampwwwget_cat.php on line 18

View 1 Replies View Related

Insert Variables Into A JSON String?

Feb 13, 2010

I am using a REST API to POST attributes to a person using json. My request body looks like this:

$requestBody = '
"attribute": {
"@id": "",
"@uri": "",
"person": {
"@id": "222",

How do I change the person id, person uri and attribute id to be variables I have already stored?

View 2 Replies View Related

Debug Script Code In The Vein JavaScript With Firebug Or XCode?

Apr 9, 2010

I find var_dump and print_r functions to be excellent for debugging variables, function calls and arrays respectively. The problem is I have been asked to debug code on a live site (no dev site, I know it is a horrible practice but this is not my project from the start.) So I would like to know what core function or php library or whatever else it is that I could use to log debugging calls in to log that I can check so I don't have to send debugging calls to the browser on a live site?

I like the way you can use the console.log function in JavaScript code and check it in Firebug or the Webkit Console and I also like like the console window in Xcode and I was wondering if there was some similar tool for PHP debugging.

View 3 Replies View Related

Insert Block Of Html Into A Page From A Json Response With Jquery?

Aug 22, 2009

<script type="text/javascript">
var dataString2 = 'run=captchagood&comment=' + comment;
type: "POST",
url: "process.php",


the list cells alternate background color in my script, so how could I make it insert class="thread-even" or class="thread-odd" depending on the last item?

View 4 Replies View Related

IPhone Websites - Detect The Browser And That Its The Specific Safari IPhone Browser?

Apr 9, 2010

I would like to begin to develop a website in PHP for an iPhone.

1. Can I detect the browser and that its the specific Safari iPhone browser?

2. Can I limit the webpage I develop in PHP to only be the screen size of the iPhone?

View 1 Replies View Related

Pass A String From File.php To File.Xcode?

Mar 28, 2011

Can I pass a string from file.php to file.Xcode DIRECTLY? Not from file.Xcode to file.php

View 1 Replies View Related

Convert Mysqli Result To Json / Format As Json For A Mobile Application?

Jul 28, 2010

I have a mysqli query which i need to format as json for a mobile application.

I have managed to produce an xml document for the query results, however i am looking for something more lightweight. (see below for my current xml code)

$mysql = new mysqli(DB_SERVER,DB_USER,DB_PASSWORD,DB_NAME) or die('There was a problem connecting to the database');

$stmt = $mysql->prepare('SELECT DISTINCT title FROM sections ORDER BY title ASC');
// create xml format
$doc = new DomDocument('1.0');
// create root node
$root = $doc->createElement('xml');
$root = $doc->appendChild($root);

View 3 Replies View Related

Building A JSON Structure / When Attempting To Output The Links In JSON, It's Only Outputting One Image Filename?

Mar 2, 2011

First of all, I'm uploading multiple images that goes through a for loop by the input file with multiple selections (HTML5), however when attempting to output the links in JSON, it's only outputting one image filename, even when I've selected 2+ images.

This is how I'm creating the JSON (the important parts, not the full script):

$count = 0;
$image_count = count($_FILES['file']);
for($i = 0; $i < $image_count; $i++)
$filename = random(13) . fileExt($_FILES['file']['name'][$i]);
move_uploaded_file($_FILES['file']['tmp_name'][$i], 'images/' . $filename);
$output = array();

I need it to be to similar to what I need it to be so I can parse it with jQuery.

View 2 Replies View Related

JQuery Does Not Return A JSON Object To Firebug When JSON Is Generated?

May 27, 2010

The contents of test.json are:

{"foo": "The quick brown fox jumps over the lazy dog.","bar": "ABCDEFG","baz": [52, 97]}

When I use the following jQuery.ajax() call to process the static JSON inside test.json,

url: 'test.json',
dataType: 'json',[code]....

I get a JSON object that I can browse in Firebug.However, when using the same ajax call with the URL pointing instead to this php script:

$arrCoords = array('foo'=>'The quick brown fox jumps over the lazy dog.','bar'=>'ABCDEFG','baz'=>array(52,97));
echo json_encode($arrCoords);

which prints this identical JSON object:

{"foo":"The quick brown fox jumps over the lazy dog.","bar":"ABCDEFG","baz":[52,97]}

I get the proper output in the browser but Firebug only reveals only HTML. There is no JSON tab present when I expand GET request in Firebug.

View 2 Replies View Related

Submit Form Using Json To Another Page And Parse Json In JQuery?

Nov 11, 2010

I know this seems like I should have immediately found the one example out there that simply explained this concept, and I can't find the right one. The examples in tutorials out there use flickr as the request url, and I get it up to a point. I'm trying to handle a very complex form with four different buckets of info under one larger bucket of info. I though json would be a good choice. So I found an example that shows me how to serialize the data like this:

$.fn.serializeObject = function()
var o = {};[code]....

Which is great! Via an alert, I can see the json structure and my form elements. So I thought the rest would be totally simple. And here I am banging my head because I can't find one simple example of HOW to SEND or REQUEST this serialized data from my processing page which needs to print, organize and calculate the values of what was sent.So what I did next (and I'm sure it's wrong, but perhaps this will illustrate how new I am to it and where I need to start in my understanding of it) was to write the serialized data out to a hidden field like so:

$('form').submit(function() {
var field = '<input type="hidden" name="jsonval" value="' + $.toJSON($('form').serializeObject()) + '">';
// alert($.toJSON($('form').serializeObject()));[code]....

I'm using the GET method in the form and when it pops the alert it looks fine, then it goes to the next page. Only that hidden var I wrote out isn't there. The rest of the form values are. I just WANT to see the darn json somehow so I can then use json.parse or whatever I have to use in PHP to decode it.

Here's the complete code:

<html lang="en">
<head> [code]....

How do I get it to just communicate in some fashion with the receive.php page?

View 1 Replies View Related

Convert Json Object Into Array If Json Value Contains Encoded Data?

Jul 23, 2010

I am trying to convert json data in to array using php. But unfortunately my json data contains encoded values. For this reason why i am unable to convert this json object in to array in php. I tried it in different ways, But i couldn't get any solutions to solve this.This is the URL data i am getting from client side.



View 2 Replies View Related

Discern An IPhone 3G/S Visitor To An IPhone 4 Visitor?

Aug 9, 2010

I want to load higher resolution pictures for iPhone 4 users, but the only way I know of detecting users is by a user-agent. But I'm under the impression that the user-agent of MobileSafari on any iOS4 phone is the same across the board.

What could I do to detect an iPhone 4?

View 2 Replies View Related

Convert JSON In Print Format To Valid JSON?

Sep 26, 2010

I have a text file that is formatted like JSON, but in a print/view friendly format and I want to convert that string to valid JSON.Basically, I want to read the file using PHP5 and call json_decode to deserialize the string.But, json_decode is not able to parse the "print-friendly" json string.I am getting error 4 Invalid or malformed JSON.

It looks like someone else had a similar issue as me: http:[url]....

I am using notepad++ to write the json file.So, how can I convert


"data": [

I even tried doing the following:

$filename = "links.json";
$file = fopen($filename, "r");[code]....

I did a var_dump of the resulting json string and http:[url].... marked it as valid json; however, json_decode is not able to deserialize the json string for some reason.

I set the encoding of the text file to UTF-8 without BOM and it works fine now.

View 1 Replies View Related

Change Json Key Name [json Generated Using Json_encode]

May 6, 2011

I am generating json from an array using json_encode(), it's working properly, but it uses the key:value from the array, as usual. but I want to change the name of the key only in the json output.. is it possible to do it ? or should I prepare the json key:values myself manually?

$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
echo json_encode($arr);

I want .


edit : I cannot edit the original array..( generated using framweork)

View 2 Replies View Related

Validates A JSON Object Against A JSON Schema?

May 3, 2010

Is there any PHP library that validates a JSON object against a JSON Schema?

View 2 Replies View Related

Get Response As Json Format(application/json) In Yii?

May 13, 2010

How to get response as json format(application/json) in yii?

View 2 Replies View Related

JSON Object To .json File On Server?

Oct 13, 2010

Write JSON object to a .json file on the server.

JavaScript Code:function createJsonFile() {
var jsonObject = {
"metros" : [],


View 2 Replies View Related

Multidimensional Array - Latest JSON Object Instead Of All JSON Object ?

Apr 18, 2010

i've got a SQL query which returns multiple rows, and i have :

$data = array(
"nom" => $row['nom'] ,
"prix" => $row['rapport'],
"average" => "$moyenne_ge"

which is perfect, but only if my query returns one row.

i tried that :

$data = array();
$data[$row['nom']]["nom"] = $row['nom'] ;
$data[$row['nom']]['average'] = "$moyenne_ge";

in order to have :

$data[brand1][nom] = brand1
$data[brand1][average] = 150$
$data[brand2][nom] = brand2
$data[brand2][average] = 20$

but when i do : json_encode($data).i only have the latest JSON object instead of all JSON object from my request as if my array has only one brand instead of 10.

View 3 Replies View Related

Json Response Opens As Dialogue Box In Php And Json Response Format?

May 24, 2011

$result=mysql_query("select * from pointtable where Latitude between '$latitude1' and '$latitude2' and Longitude between '$longitude1' and '$longitude2' ");


above code is of creating json response..i have one form from which by POST method i am getting parameter information..result is fine but it opens in diagloue box..i want to type this json response in a page...what do i do?..

i donot want this starting...{"posts":"post'}..want to start it from {id:1...}what do i change?...

View 1 Replies View Related


Nov 28, 2007

Does anyone know how to tell if your using an iPhone to view a site yet?, cause I wanna make a totally different site then.

View 8 Replies View Related

IPhone Sdk Getting Data

Aug 11, 2010

I want to read a mysql database, one method is to serve the data over php. My php file looks like this:

$db_verbindung = mysql_connect("localhost", "root","") or die
("Keine Verbindung moeglich");
$db = mysql_select_db("testdb") or die
("Die Datenbank existiert nicht.");
$querystring = $_POST['querystring'];
$result = mysql_query($querystring) or die(mysql_error());

View 2 Replies View Related

Create Iphone API For Aweber?

Jan 20, 2011

I have to create a iphone app using Aweber. But Aweber has no iphone API link. Now I just want to know that I have knowledge of PHP and aweber has PHP API, is it possible to create a iphone API for a newbie like me (I mean for Iphone) to accomplish this task.

View 4 Replies View Related

Different Scaling On IPhone/iPad?

Apr 13, 2011

I'm trying to finish a site for my friends brother, and everything (almost) works fine.The site is built with a centered container, aprox 15-20% space from the left side.The problem is though that when you open it in iPhone or iPad the site is scaled so that the space on the left side is removed, the text starts exactly where the screen starts. I hope I'm explaining this right.

Is there a simple way for me to change this only for mobile devices? Too bad I don't have any experience when it comes to designing for phones.

View 2 Replies View Related