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 4618584
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:17:17+00:00 2026-05-22T02:17:17+00:00

I am doing serverside work for my iPhone app, and for some reason the

  • 0

I am doing serverside work for my iPhone app, and for some reason the imageData will not upload. I would appreciate it if you could take a look at my PHP code, and tell me whether there is a problem.

addImage.php is called after the addrecipie method has been called.

My Obj-c code for uploading the image is:

NSString *name =  [@"Name: " stringByAppendingFormat:@"%d", arc4random()%20091011];
    NSString *username = [@"User: " stringByAppendingFormat:@"%d", arc4random()%20091011];
    NSString *description =  [@"Description: " stringByAppendingFormat:@"%d", arc4random()%20091011];
    NSString *shortDescription =  [@"ShortDescription:  " stringByAppendingFormat:@"%d", arc4random()%20091011];
    SBJsonWriter *writer = [[SBJsonWriter alloc] init];
    NSArray *array = [NSArray arrayWithObjects:@"llama", @"30", @"beef", @"beef", @"beefy", nil];
    NSString *ingredients = [writer stringWithObject:array];
    NSString *method = ingredients;
    NSString *category = @"Health";
    NSString *length = @"20";
    [writer release];
    NSArray *arr = [NSArray arrayWithObjects:name,description,shortDescription,ingredients,method,UIImageJPEGRepresentation([UIImage imageNamed:@"cupboard.jpg"], 1.0),username,length,category, nil];
    NSDictionary *dict = [[NSDictionary alloc] initWithObjects:arr forKeys:recipieKeys];
    [[AccountManager sharedManager] addRecipie:dict];
    [dict release];

- (NSString *)addRecipie:(NSDictionary *)recipie {
    NSData *data = [recipie objectForKey:@"image"];
    //form data away....

    NSString *url = [NSString stringWithFormat:@"http://...com/(..).php?name=%@&description=%@&shortDescription=%@&ingredients=%@&method=%@&username=%@&length=%@&category=%@", [recipie objectForKey:@"name"], [recipie objectForKey:@"description"], [recipie objectForKey:@"shortdescription"], [recipie objectForKey:@"ingredients"], [recipie objectForKey:@"method"], [recipie objectForKey:@"username"], [recipie objectForKey:@"length"], [recipie objectForKey:@"category"]];
    NSString *escaped = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];   
    [escaped stringByReplacingOccurrencesOfString:@"$" withString:@"%24"];
    [escaped stringByReplacingOccurrencesOfString:@"&" withString:@"%26"];
    [escaped stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"];
    [escaped stringByReplacingOccurrencesOfString:@"," withString:@"%2C"];
    [escaped stringByReplacingOccurrencesOfString:@"/" withString:@"%2F"];
    [escaped stringByReplacingOccurrencesOfString:@":" withString:@"%3A"];
    [escaped stringByReplacingOccurrencesOfString:@";" withString:@"%3B"];
    [escaped stringByReplacingOccurrencesOfString:@"=" withString:@"%3D"];
    [escaped stringByReplacingOccurrencesOfString:@"?" withString:@"%3F"];
    [escaped stringByReplacingOccurrencesOfString:@"@" withString:@"%40"];
    [escaped stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
    [escaped stringByReplacingOccurrencesOfString:@"\t" withString:@"%09"];
    [escaped stringByReplacingOccurrencesOfString:@"#" withString:@"%23"];
    [escaped stringByReplacingOccurrencesOfString:@"<" withString:@"%3C"];
    [escaped stringByReplacingOccurrencesOfString:@">" withString:@"%3E"];
    [escaped stringByReplacingOccurrencesOfString:@"\"" withString:@"%22"];
    [escaped stringByReplacingOccurrencesOfString:@"\n" withString:@"%0A"];
    ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:escaped]];
    [req startAsynchronous];
    if (![req error]) {
        NSString *ids = [req responseString];
        ASIFormDataRequest *reqs = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:[@"http://maxkdevelopment.co.uk/recipes/addimage.php?id=" stringByAppendingFormat:@"%@", [ids stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]]];
        [reqs setData:data forKey:@"image"];
        [reqs startAsynchronous];
        if (![reqs error]) {
            return [reqs responseString]; 
        }
        else {
            return [[reqs error] description]; 
        }
    }
    else {
        NSLog(@"%@", [[req error] description]);
    }
    return @"";
}

(addImage.php)

<?php
$id = $_GET['id'];
mysql_connect(...);
mysql_select_db("...") or die(mysql_error());
$query = "SELECT * FROM recipies WHERE id=$id";
$result = mysql_query($query);
if (mysql_num_rows($result) > 0) {
$sql = sprintf("UPDATE recipies SET Image = '%s' WHERE id=$id", mysql_real_escape_string(file_get_contents($_FILES["image"]["tmp_name"])));
$results = mysql_query($sql) or die(mysql_error());
$error = mysql_error();
echo "error: $error";
}
?>

(GetImage.php)

<?php
$id = $_GET['id'];
mysql_connect(...);
mysql_select_db(...");
$query = "SELECT * FROM recipies WHERE id=$id";
$result = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_assoc($result)) {
        echo $row['Image'];
    }
}
?>

(Add Recipe.php)

<?php
function uk_date() {
    $sign = "-"; 
    $h = "0"; 
    $dst = "true"; 
    if ($dst) {
        $daylight_saving = date('I');
        if ($daylight_saving){
           if ($sign == "-"){ $h=$h-1;  }
           else { $h=$h+1; }
      }
    }
    $hm = $h * 60;
    $ms = $hm * 60;
    if ($sign == "-"){ $timestamp = time()-($ms); }
    else { $timestamp = time()+($ms); }
    return $gmdate = gmdate("d/m/Y g:i:s A", $timestamp);
}
$name = $_GET['name'];
$description = $_GET['description'];
$shortDescription = $_GET['shortDescription'];
$ingredients = $_GET['ingredients'];
$category = $_GET['category'];
$method = $_GET['method'];
//$image = $_GET['image'];
$username = $_GET['username'];
$length = $_GET['length'];
$dateAdded = uk_date();
$conn = mysql_connect('...');
mysql_select_db('...');
$query = sprintf("INSERT INTO recipies (Name, Description, shortDescription, Ingredients, Method, Length, dateAdded, Username, Category) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
    mysql_real_escape_string($name),
    mysql_real_escape_string($description),
    mysql_real_escape_string($shortDescription),
    mysql_real_escape_string($ingredients),
    mysql_real_escape_string($method),
    mysql_real_escape_string($length),
    mysql_real_escape_string($dateAdded),
    mysql_real_escape_string($username),
    mysql_real_escape_string($category));

    $result = mysql_query($query) or die(mysql_error());

    $query2 = "SELECT * FROM `recipies` WHERE `Name` = $name AND `shortDescription` = $shortDescription";
    $result2 = mysql_query($query2) or die(mysql_error());
    if (mysql_num_rows($result2) > 0) {
        while($row = mysql_fetch_assoc($result2)) {
        die($row['id']);
        }
    }
?>
  • 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-22T02:17:18+00:00Added an answer on May 22, 2026 at 2:17 am

    You’ve spelt recipe “recipie” in the addImage.php SQL. Unless your table name is spelt incorrectly then the script will be returning 0 rows and not running the subsequent queries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing some work with a server side service I don't control. The following
We are developing an iPhone app that would send emoticons from iPhone to server-side
I'm doing some work with WebSQL: creating an object to send via ajax to
I'm building a WPF application. I'm doing some async communication with the server side,
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
Doing some jquery animation. I have certain divs set up with an attribute of
I'm developing an iPhone app that relies heavily on calling ASP.NET Webservices to transfer
Recently I updated a Crystal Report that was doing all of its work on
I am getting started with iPhone application development and would like to create an
I could reproduce my bug using servside OAuth2.0 only so it's not javascript and

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.