title: insert a string(with spaces) into mysql using php from my iphone app
body: <p>I am trying to save a string (Address) entered by a user in my iphone app into mysql database. I am using php to accomplish this. I have a few problems.</p>
  
  <p>Here is my code in php:</p>
  
  <pre><code>...
  $guestadd1 = $_GET["guestadd1"];
  $guestadd2 = $_GET["guestadd2"];
  $guestcity = $_GET["guestcity"];
  ...
  </code></pre>
  
  <p>And here is the mysql query:</p>
  
  <pre><code> mysql_query( "INSERT INTO HMS_GUESTS( GUESTTYPE, GUESTLNAME, GUESTFNAME, GUESTADDRESS1,
                 GUESTADDRESS2, GUESTCITY, GUESTSTATE, GUESTPOSTCODE, GUESTWORKPHONE) VALUES 
                 ('$guestType', '$guestLname', '$guestFname', '$guestadd1', '$guestadd2', 
                 '$guestcity', '$gueststate', '$guestpostal', '$guestWphone') ", $con) or 
                 die(mysql_error());
  </code></pre>
  
  <p><strong>1</strong>
  But I am unable to insert the data with spaces. If I try saving it without space, I am able to insert. How can i insert with spaces? </p>
  
  <p><strong>2</strong>
  I have two types of guests: Personal and Professional. So, more than one entry can have the same guest types. So, when I am trying to insert the second guest from one type, I am getting Duplicate value for key error. How can I overcome this and insert the entry?</p>
  
  <p>Any help appreciated. Thank you :)</p>
  
  <p><strong>EDIT</strong>
  Including my objective-c code</p>
  
  <pre><code>NSString *strURL = [NSString stringWithFormat:@"http://127.0.0.1/hms.php?guesttype=%@&amp;
  guestLname=%@&amp;guestFname=%@&amp;guestadd1=%@&amp;guestadd2=%@&amp;guestcity=%@&amp;
  gueststate=%@&amp;guestpostal=%@&amp;guestWphone=%@", guestID, self.name1.text, self.name2.text,
  self.address1.text, self.address2.text, self.city.text, self.state.text, self.postal.text,
  self.phone.text, self.fax.text];
      // to execute php code
  NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
  
      // to receive the returned value
  NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
  </code></pre>
  
  <p>And mysql table structure:</p>
  
  <pre><code>Guest Type  | Guest First Name | Guest Last Name | ADDRESS LINE 1 | ADDRESS LINE 2 | CITY | STATE | POSTAL |  WORKPHONE
  ----------------------------------------------------------------------------------------------------------------------
  Personal    | blah             |  blah           | blah            | blah          | blah | blah  | blah   |  blah
  Professional| blah             |  blah           | blah            | blah          | blah | blah  | blah   |  blah
  </code></pre>
  
  <p>SO, in the address columm or possibly anywhere..i will come across spaces in arguments which i am not able to insert.</p>
  
  <p>And if I now try to add another guest to the table, say type Personal, I am getting this error: Duplicate entry '1-1-PERSONAL-11' for key 1</p>