Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5845687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:28:13+00:00 2026-05-22T12:28:13+00:00

I’m writing a simple php/mysql script that gets all ads I have in my

  • 0

I’m writing a simple php/mysql script that gets all “ads” I have in my database and returns them in JSON format. This works great if I’m only returning one row, ten the parser will split each string into an index om the array. But now I have this PHP code:

    <?php
   // Database credentials
   $host = 'localhost'; 
   $db = 'project'; 
   $uid = 'root'; 
   $pwd = '';

   $SSN = $_GET['ssn'];

    // Connect to the database server   
    $link = mysql_connect($host, $uid, $pwd) or die("Could not connect");

   //select the json database
   mysql_select_db($db) or die("Could not select database");

   // Create an array to hold our results
   $arr = array();

   //Execute the query
   $rs = mysql_query("SELECT * FROM all_ads WHERE SSN = $SSN ORDER BY datePosted");



   // Add the rows to the array 
   while($obj = mysql_fetch_row($rs)) {
   $arr[] = $obj;
   }

   echo json_encode($arr);

?>

And it returns the following format:

[["4","Hyr ut i natt","321654987","couch_surfing_ads","2011-05-16 13:49:58"],["5","Maybe not","456893214","vacation_resident_ads","2011-05-16 14:22:34"]]

(CONTAINING TWO SEPARATE ADS)

When xcode gets this array back it puts the entire first ad in one index of the array.
How do I to also put each array in an array like the JSON output does?

How do I process/deserialize this data is my core question!

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:28:13+00:00Added an answer on May 22, 2026 at 12:28 pm

    I think you just need to have a two layer reference (last line below) unless I’m misunderstanding something:

    NSString *response = [[NSString alloc] initWithContentsOfURL:yourSourceUrl];
    const char *convert = [response UTF8String];
    NSString *responseString = [NSString stringWithUTF8String:convert];
    NSArray *ads = [responseString JSONValue];
    NSLog(@"%@",[[ads objectAtIndex:0] objectAtIndex:1]); //Hyr ut i natt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.