scm22ri Posted July 26, 2012 Share Posted July 26, 2012 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> Quote Link to comment https://forums.phpfreaks.com/topic/266289-how-do-i-get-rid-of-backslashes/ Share on other sites More sharing options...
Pikachu2000 Posted July 26, 2012 Share Posted July 26, 2012 Turn off magic_quotes_gpc() in your PHP.ini file and restart apache. Then you'll have to run an update query to get rid of the ones already in the database. Quote Link to comment https://forums.phpfreaks.com/topic/266289-how-do-i-get-rid-of-backslashes/#findComment-1364592 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.