RE: [PHP-WIN] Inserting symbols into a mysql database from PHP

From: Date: Mon, 15 Oct 2001 20:39:31 +0000
Subject: RE: [PHP-WIN] Inserting symbols into a mysql database from PHP
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-9865@lists.php.net to get a copy of this message
Thanks everyone. I've just finished a looooooot of playing and I managed to do it eventually. I did a very long-winded way using both the stripslashes and urlencode functions and stored the data in the table as a url encoded piece of text and decode them whenever the need to be read now. The problem was that each time it went through the script it was getting a \ added at the front. As for the javascript idea, I thought about that, but I haven't learnt any javascript yet, but will use that when I get around to learning it. Cheers for all the input Ross -----Original Message----- From: Egil Helland [mailto:egil@egil.net] Sent: 15 October 2001 20:59 To: R7019C@motorola.com; 'r.fleming@clara.co.uk'; php-windows@lists.php.net Subject: RE: [PHP-WIN] Inserting symbols into a mysql database from PHP function quote($var) { if (is_string($var)) { if (strlen($var)>0) { $var="'" . str_replace("\'","\\'",$var) . "'"; } else { $var="NULL"; } } return $var; } $sql=" Select blablabla from whatever where something=" . quote($variable) . " and so forth"; Regards, Egil On Mon, 15 Oct 2001 12:46:31 -0700, Corn Vollney-R7019C wrote: >Ross, > >A better way to validate your form is to use javascript on the >client side, once the form is validated (using the clients computer >power) you can then send the data to a php script via get or post, >and have it processed further. > >V > >-----Original Message----- >From: Ross Fleming [mailto:r.fleming@totalise.co.uk] >Sent: Monday, October 15, 2001 6:14 PM To: php-windows@lists.php.net >Subject: [PHP-WIN] Inserting symbols into a mysql database from PHP > > >Hi all, > >My problem is that that I have a form that takes user data and >inserts it into a database. How can I allow quote marks to be >inserted into the database? ie if someone puts a " mark in the form >field then php/mysql recognises that as the end of the data I'm >trying to insert. I tried urlencode-ing the data before inserting >it and urldecode-ing it when reading it, but it didn't help. > >Any suggestions? Surely this must be possible? > >Thanks in advance > >Ross > > >-- >PHP Windows Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net For >additional commands, e-mail: php-windows-help@lists.php.net To >contact the list administrators, e-mail: php-list- >admin@lists.php.net -=// Egil Helland / IKON AS - MCSE, Internet, Intranet mailto:egil@egil.net http://egil.net //=- -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net For additional commands, e-mail: php-windows-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.windows (#9865) next »