Jump to content

Spaces in data that needs to be saved


cliftonbazaar

Recommended Posts

$query = "SELECT * FROM friends";
  $sql_statement = "UPDATE friends SET ";
  $column = "memberName";
  $values = "'$_POST[memberName]'";
  
  if ($result = $mysqli->query($query)) {
    /* Get field information for all columns */
    while ($info = $result->fetch_field()) {
      if($info->name <> 'memberID') {  //If the column isn't memberID
        if($info->name == 'memberName') {  //If the column is the memberName
          $sql_statement .= $info->name."='".$_POST[$info->name]."'";
        } else {  //Put the commas in
          $sql_statement .= ", ".$info->name."='".$_POST[$info->name]."'";
        }
      }
    } 
    $result->close();
  }
  $sql_statement .= " WHERE memberID='$_REQUEST[member]'";

now if I echo the $sql_statement it all works fine - EXCEPT if the data has a space in it, which the Address column nearly always does - if the Address is 'Box 73' it only saves the 'Box' part, how do I get it to save all of the address?

Link to comment
Share on other sites

Did you look directly in your database to see what exactly is being saved? If you do, you will find that the data is saved correctly.

 

Your problem is most likely invalid HTML where you output/echo the contents. This problem is usually due to missing quotes around the data value when you output it into form fields.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.