Page 1 of 1

insert query

Posted: Wed Jul 14, 2004 9:05 am
by gurjit
hi all,

i have a variable with the following text

Code: Select all

<?php
$school = "Noah's Ark Pre-School";
?>
when i insert into the databse it never goes into the database because of the ' in the text. how can i avoid this....

my insert query is as follows

Code: Select all

<?php
insert into my_table (schoolf) values ('$school')

?>

Posted: Wed Jul 14, 2004 9:13 am
by Buddha443556

Code: Select all

<?php 
$school = addslashes( "Noah's Ark Pre-School" );

// or

$school = mysql_escape_string( "Noah's Ark Pre-School" ); 
?>
mysql_escape_string()

or

addslashes

Posted: Wed Jul 14, 2004 10:39 am
by gurjit
how can i get rid of the slashes by using the mysql_escape_string function. this stores \ in the database.

Posted: Wed Jul 14, 2004 10:41 am
by PrObLeM

Posted: Wed Jul 14, 2004 11:11 am
by Buddha443556
gurjit wrote:how can i get rid of the slashes by using the mysql_escape_string function. this stores \ in the database.
If your seeing slashes you may want to read up on Magic Quotes.