Jump to content


Photo

Displaying variables in a form that has spaces in it???


  • Please log in to reply
3 replies to this topic

#1 my_r31_baby

my_r31_baby
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 14 July 2006 - 05:04 PM

I originally thought it was the database it was having trouble getting it from so that why i am trying to go from _ to " "...


Here is my script:

<?php
include("../db.php");

session_start();
$u_pk = $_SESSION['u_pk'];


$sql = "SELECT * FROM pb_users WHERE pb_users_userid = '$u_pk' " ;
// echo $sql;
$result = mysql_query( $sql ) or die ( 'Unable to execute query.' );
$num = mysql_num_rows( $result );

while ($row = mysql_fetch_assoc($result)) { 
$fname = $row['pb_users_firstname'];
$lname = $row['pb_users_lastname'];
$homeaddress = $row['pb_users_homeaddress'];
$townsub = $row['pb_users_townsub'];
$state = $row['pb_users_state'];
$postcode = $row['pb_users_postcode'];
$emailaddress = $row['pb_users_emailaddress'];
$homephone = $row['pb_users_homephone'];
$mobilephone = $row['pb_users_mobilephone'];

$homeaddress2 = eregi_replace("_", " ", $homeaddress);
};
?>


<tr>
        <td>First Name: <font color="#FF0000">*</font></td>
        <td><input type="text" name="first" value= <?php echo $fname ; ?> size="40%"></td>
      </tr>
  <tr>
        <td>Last Name: <font color="#FF0000">*</font></td>
        <td><input type="text" name="last" value= <?php echo $lname ; ?> size="40%"></td>
      </tr>
    <tr>
        <td>Address: <font color="#FF0000">*</font></td>
        <td><input type="text" name="address" value= <?php echo "$homeaddress2" ; ?> size="40%"></td>
      </tr>  
  <tr>
        <td>Town/Suburb<font color="#FF0000">*</font></td>
        <td><input type="text" name="townsuburb" value= <?php echo $townsub ; ?> size="40%"></td>
      </tr>

#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 14 July 2006 - 05:10 PM

you need to include the value in " in your HTML
<input type="text" name="first" value= "<?php echo $fname ; ?>" size="40%">

NoGray.com


#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 14 July 2006 - 05:10 PM

Always use quotes when entering values in <input>s:
<td><input type="text" name="first" value="<?php echo $fname ; ?>" size="40%"></td>

Ken

#4 my_r31_baby

my_r31_baby
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 14 July 2006 - 05:23 PM

cheers dude that worked sweet...

Thanks..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users