Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove leading slash

Status
Not open for further replies.

supportahm1980

Technical User
May 30, 2006
208
US
Hello. I was wondering what I can do to remove a leading slash when data is displayed on a webpage after a mysql query.


For example:
<?php
while ($row = mysql_fetch_assoc($rs)) {
echo "<tr><td>".$row['Name']."</td><td>";
?>

Result is \John

\John is in the DB.
 
Yea that is probably it but not sure of the best way to fix it. The data I am actually trying to insert is a domain controller name so it would be \\foo. One of the slashes disappears the other does not.
 
It's not that either slash disappears. It's that the backslash character is the escape character in MySQL. Since like in PHP, MySQl denotes a newline as "\n" and a carriage return as "\r", MySQL uses "\\" to represent a single backslash.

Your code to input data into the table needs to run all those values through mysql_escape_string() before inserting them into the table.

I strongly recommend that you correct your insertion code and data first.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top