Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2006
    Posts
    31

    Looking for PHP Advice. Inserting only the first word

    I am trying to pass a variable from one page to another by url (.php?id=".$pi."&name=".$row['title']."). Then I attempt to insert $id and $name into a database on the new page. There is a problem however. If a name is two words, it only inserts the first word, excluding the second. Any advice?

  2. #2
    well you can do this :
    Code:
    $i=$row["title"];
    $i= str_replace(' ','%20', $i);
    and pass $i as the title variable. It should work.
    Cheap web hosting
    Any CMS pre-installed
    Joomla Hosting

  3. #3
    Join Date
    Jun 2003
    Location
    Sydney, Australia
    Posts
    158
    Quote Originally Posted by maiahost
    well you can do this :
    Code:
    $i=$row["title"];
    $i= str_replace(' ','%20', $i);
    and pass $i as the title variable. It should work.
    Or even still:

    PHP Code:
    $row["title"] = urlencode($row["title"]); 
    and then before you insert it into the database you would use:
    PHP Code:
    $name urldecode($name); 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •