I have a problem updating my database in a similar way.
Sql Operators
<?php // Create connection $con=mysqli_connect("server_name","user_name","user_code","table_name"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // This SQL statement selects ALL from the table 'table.name' $sql = "SELECT * table_name"; // Check if there are results if ($result = mysqli_query($con, $sql)) { // If so, then create a results array and a temporary one // to hold the data $resultArray = array(); $tempArray = array(); // Loop through each row in the result set while($row = $result->fetch_object()) { // Add each row into our results array $tempArray = $row; array_push($resultArray, $tempArray); } // Finally, encode the array to JSON and output the results echo json_encode($resultArray); } $sql = "INSERT INTO table_name (column_name) VALUES('1')"; // Close connections mysqli_close($result); mysqli_close($con); ?>
My iOS code
for (Tickets *items in _feedItems){ if ([resultText.text isEqual:(id) items.ticketNumber]) { status.text = @"Match found"; //Contacting database------------------------------ NSString *strURL = [NSString stringWithFormat:@"TicketDate=%@", items.ticketDate]; NSData *postData = [strURL dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:@"http://webservice.com"]]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current- Type"]; [request setHTTPBody:postData]; NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self]; if(conn) { NSLog(@"Connection Successful"); } else { NSLog(@"Connection could not be made"); } //Contacting database END------------------------------------------- break; }else { status.text = @"Match not found"; } }
I get a connection from NSLog but nothing is updated in my database.
I am trying to manually enter the ticket number with the application, and if this matches the ticket in the database (it works), then I want the ticketDate property to change from 0 to 1.
But this does not change: /
source share