Jump to content

Archived

This topic is now archived and is closed to further replies.

my_r31_baby

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

Recommended Posts

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>

Share this post


Link to post
Share on other sites
you need to include the value in " in your HTML
[code]
<input type="text" name="first" value= "<?php echo $fname ; ?>" size="40%">
[/code]

Share this post


Link to post
Share on other sites
Always use quotes when entering values in <input>s:
[code]
<td><input type="text" name="first" value="<?php echo $fname ; ?>" size="40%"></td>
[/code]

Ken

Share this post


Link to post
Share on other sites

×

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.