\ inserted when user input '

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
justinb
Forum Newbie
Posts: 11
Joined: Fri Dec 06, 2002 12:11 am

\ inserted when user input '

Post by justinb »

Hello,
i have a form that inserts peole into database, when they have been inserted they go to a page which shows all information that was inserted. But if anyone uses a ' apostopy, the show page dosplays this

name''s

the db info is right, but whats happeneing is that people are telling me their is a mistake because of the \ anyway to get rid of this

exapmle of input page

<tr valign="top" bgcolor="#FFFFFF">
<td><font size="2" face="Arial, Helvetica, sans-serif">Business Name:</font></td>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input name="busName" type="text" id="businessName" size="35" maxlength="75">
</font></td>
</tr>


example of showing inouted results page

<td width="249"><strong><font size="2" face="Arial, Helvetica, sans-serif">Business
Name: </font></strong></td>
<td width="238"><? echo "$busName"; ?></td>
</tr>
User avatar
nathus
Forum Commoner
Posts: 49
Joined: Thu Dec 12, 2002 6:23 pm

Post by nathus »

look up stripslashes() on php.net
justinb
Forum Newbie
Posts: 11
Joined: Fri Dec 06, 2002 12:11 am

Post by justinb »

thanks again nathus,
But how do i use them, i tried this

<input name="busName" type="text" id="businessName" size="35" maxlength="75" value="<? echo(stripslashes("$busName";)) ?>">

but i get an error
Next_Gate
Forum Newbie
Posts: 15
Joined: Fri Dec 20, 2002 4:54 pm

Post by Next_Gate »

the same happens to me but when i insert a " double quote... when i use the single quote i receive a mysql db error
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

just:

Code: Select all

<? echo stripslashes($var); ?>
justinb
Forum Newbie
Posts: 11
Joined: Fri Dec 06, 2002 12:11 am

Post by justinb »

u da goblin

thanks
Next_Gate
Forum Newbie
Posts: 15
Joined: Fri Dec 20, 2002 4:54 pm

Post by Next_Gate »

that worked great.. and what about the single quote(')??? how can prevent that for breaking the sql query!
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

if you're talking about how it needs slashes in the query, there is also the function addslashes()
Post Reply