By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

urgent help on sanitize function

pradeepjain
100+
P: 563
This is the function that i use to remove all quotes and things.But this time its giving error y i dont know.

[PHP]function sanitize($input){
if(is_array($input)){
foreach($input as $k=>$i){
$output[$k]=sanitize($i);
print($output[$k]);
}
}
else{
if(get_magic_quotes_gpc()){
$input=stripslashes($input);
}
$output=mysql_real_escape_string($input);
}

return $output;
}
print_r($INFO);
$INFO=sanitize($INFO);
print_r($INFO);[/PHP]


this is printed by the 1st print_r
Array ( [fname] => ass'p [lname] => eerr [profStatus] => phd-student [affiliation] => IIAP [address] => jhhh [state] => hhh [country] => hh [pincode] => hh [email] => rasdssk@gmail.com [membership] => no [support] => not-required [submitReg] => true [regID] => AE750817 [regtimeStamp] => 1222850719 )


and this by 2nd
Array ( [fname] => [lname] => [profStatus] => [affiliation] => [address] => [state] => [country] => [pincode] => [email] => [membership] => [support] => [submitReg] => [regID] => [regtimeStamp] => )

please tell me where i am going wrong.after the sanitize the value is getting lost...
Oct 1 '08 #1
Share this Question
Share on Google+
5 Replies


Atli
Expert 5K+
P: 5,058
Are you getting any errors?
If not, is error reporting turned on?

It looks like the mysql_real_escape_string function is returning FALSE.
Have you change your MySQL setup at all?
Oct 1 '08 #2

pradeepjain
100+
P: 563
Are you getting any errors?
If not, is error reporting turned on?

It looks like the mysql_real_escape_string function is returning FALSE.
Have you change your MySQL setup at all?
nope i haven't touched the MYSQL setup at all......ok will chk and get back if any error is there...
Oct 2 '08 #3

pradeepjain
100+
P: 563
hey its giving out this error

[Thu Oct 02 08:16:11 2008] [error] [client 122.167.235.180] PHP Warning: mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/html/xyx/processData.php on line 32, referer: http://xyx/abc/registration.php

wht should be done for this .....
Oct 2 '08 #4

pradeepjain
100+
P: 563
Hey guys i corrected the error....I put the call to sanitize function after the mysql connection and it worked.Hope this solution was correct.thanks for all help.


thanks,
Pradeep
Oct 2 '08 #5

Markus
Expert 5K+
P: 6,050
Hey guys i corrected the error....I put the call to sanitize function after the mysql connection and it worked.Hope this solution was correct.thanks for all help.


thanks,
Pradeep
Yep, you gotta remember to use mysql_real_escape_string() you need to have a connection to the database.

Markus.
Oct 2 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.