Re: working with ' in SQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Adam,

Thursday, March 4, 2004, 3:30:32 PM, you wrote:

AW> Hi, I have an SQL statement that is ran when data is submitted through a
AW> form.  When someone types in a word with an ' such as farmer's the SQL
AW> statement fails.  I tried $_POST[data] =
AW> addslashes($_POST[data]); before 
AW> executing the SQL statement, but the statement still fails.  any 
AW> suggestions?  using words without a ' works fine.

$_POST['data'] = addslashes($_POST['data']);

will work - you need the quotes or the array element won't be found.

Here is a function that will addslashes to an entire array (in this
instance $_POST) if you want:

<?
function addslash (&$item1, $key)
{
         $item1 = addslashes($item1);
}

array_walk($_POST, 'addslash');
?>

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux