-1

This is the objective-c code

NSString *CategoryID = @"2";
NSString *strURL =[NSString stringWithFormat:@"http://****/iCategoryItems.php?CategoryID=%@",CategoryID];
NSURL *url = [NSURL URLWithString:strURL];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection connectionWithRequest:request delegate:self];

And this is the php code of the icategoryitems.php page

$cid = $GET_["CategoryID"];
$sql = "SELECT * FROM items where cat_id = '".$cid."' ";

however the code as-is always returns the items with cat_id = 0

Am I sending categoryID wrong way, or reading it from the php wrong way !

jack
  • 155
  • 5
  • 14
  • First step you need to do is to enable error reporting and logging. Then set the error level to the highest level and get your code warning and notices free: http://stackoverflow.com/q/3531703/367456 - Then there is even another website to go to first: http://bobby-tables.com/ – hakre Dec 23 '14 at 18:47

1 Answers1

0

I think you mean:

$cid = $_GET["CategoryID"];
       ^^^

Your code is wiiiide open to sql injection attacks as well. You should be using PDO for your queries: http://php.net/manual/en/book.pdo.php

Madbreaks
  • 19,094
  • 7
  • 58
  • 72
  • WOW, i can't believe i didn't notice that !!! Thanks, and i will check out PDO ... thx – jack Dec 23 '14 at 18:52