Fwd: Re: [PHP] Separators in variable values causing MySQL commands to fail

From: Date: Sat, 22 Mar 2003 18:17:17 +0000
Subject: Fwd: Re: [PHP] Separators in variable values causing MySQL commands to fail
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-140702@lists.php.net to get a copy of this message
-> rentAweek, rL> In my PHP script I have coded e.g.: rL> $sql = "INSERT INTO $owners ( rL> FirstName, LastName) VALUES ( rL> '$firstname' , '$lastname' )"; rL> $result = mysql_query($sql); rL> So along comes e.g. John O'Groats and nothing gets inserted into the rL> database. rL> OK, I can bypass my oversight by stripping out apostophes from the rL> variable values. There has to be a better way please. Why not just use addslashes() (mysql_escape_string()) & check if $result==true? Yours, L0vCh1Y

« previous php.general (#140702) next »