Jump to content

How do I get rid of backslashes?


scm22ri

Recommended Posts

Hi Everyone,

 

How would I go about getting rid of backslashes for the profile section on my website?

 

http://whatsmyowncarworth.com/members/member_profile.php?id=4

 

Whenever  I use a ' I'm always getting \ in front of my words. I'm not sure how to fix this. Any tips or pointers?

 

Thanks

 

<?php
session_start(); // Must start session first thing

// See if they are a logged in member by checking Session data
$toplinks = "";
if (isset($_SESSION['id'])) {
// Put stored session variables into local php variable
    $userid = $_SESSION['id'];
    $username = $_SESSION['username'];
$toplinks = '<a href="member_profile.php?id=' . $userid . '">' . $username . '</a> • 
<a href="member_account.php">Account</a> • 
<a href="logout.php">Log Out</a>';
} else {
$toplinks = '<a href="join_form.php">Register</a> • <a href="login.php">Login</a>';
}
?>
<?php
// Use the URL 'id' variable to set who we want to query info about
$id = ereg_replace("[^0-9]", "", $_GET['id']); // filter everything but numbers for security
if ($id == "") {
echo "Missing Data to Run";
exit();
}
//Connect to the database through our include 
include_once "connect_to_mysql.php";
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM members WHERE id='$id' LIMIT 1");
$count = mysql_num_rows($sql);
if ($count > 1) {
echo "There is no user with that id here.";
exit();	
}
while($row = mysql_fetch_array($sql)){
$country = mysql_real_escape_string ($row["country"]);
$state = mysql_real_escape_string ($row["state"]);
$city = mysql_real_escape_string ($row["city"]);
$accounttype = mysql_real_escape_string ($row["accounttype"]);
$bio = mysql_real_escape_string ($row["bio"]);
$address = mysql_real_escape_string($row['address']);
$zipcode = mysql_real_escape_string($row['zipcode']);
$eyecolor = mysql_real_escape_string($row['eyecolor']);
$cool = mysql_real_escape_string($row['cool']);
// Convert the sign up date to be more readable by humans
$signupdate = strftime("%b %d, %Y", strtotime($row['signupdate']));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Profile</title>
<style type="text/css">
<!--
body {margin: 0px}
-->
</style></head>
<body>
<table style="background-color: #CCC" width="100%" border="0" cellpadding="12">
  <tr>
    <td width="78%"><h1>My Logo Image</h1></td>
    <td width="22%"><?php echo $toplinks; ?></td>
  </tr>
</table>
<table width="90%" align="center" cellpadding="5" cellspacing="5" style="line-height:1.5em;">
  <tr>
    <td width="31%" rowspan="2" valign="top">
    <div align="center"><img src="memberFiles/<?php echo "$id"; ?>/pic1.jpg" alt="Ad" width="250" /></div></td>
    <td width="20%" rowspan="2" valign="top"><b>Name</b>: 
      <?php echo $_SESSION['username']; ?>
      <br />
      <b>Country</b>: 
      <?php echo "$country"; ?>
      <br />
      <b>State</b>: 
      <?php echo "$state"; ?>
      <br />
      <b>City</b>: 
      <?php echo "$city"; ?>
      <br />
      <b>Address</b>: 
      <?php echo "$address"; ?>
      <br />
      <b>Zip Code</b>: 
      <?php echo "$zipcode"; ?>
      <br />
      <b>Eye Color</b>: 
      <?php echo "$eyecolor"; ?>
      <br />
      <b>How Cool Are You?</b>: 
      <?php echo "$cool"; ?>
      <br />
    </td>
    <td width="49%" valign="top"><b>Bio</b></td>
  </tr>
  <tr>
    <td valign="top"><?php echo "$bio"; ?></td>
  </tr>
  <tr>
    <td valign="top"> </td>
    <td colspan="2" valign="top"><b>Sign up date</b>: 
      <?php echo "$signupdate"; ?>
    </td>
  </tr>
</table>
</body>
</html>

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.