Jump to content

[SOLVED] function not working...


darkfreaks

Recommended Posts

any takers ???

 

<?php
if(get_magic_quotes_gpc())
{
//clean XSS/SQL injection
function clean_post($var) {

$var=strip_tags(trim(mysqli_real_escape_string($var)));
$var=htmlspecialchars($var,ENT_QUOTES);
return $var;
}

array_walk_recursive($_POST,'clean_post');
} 
?>

Link to comment
Share on other sites

<?php
if(get_magic_quotes_gpc())
{
//clean XSS/SQL injection
function clean_post(&$var) {

$var=strip_tags(trim(mysqli_real_escape_string($var)));
$var=htmlspecialchars($var,ENT_QUOTES);
}

array_walk_recursive($_POST,'clean_post');
} 
?>

Also, make sure get_magic_quotes_gpc() is not returning false.

Link to comment
Share on other sites

It would probably be worth your time to read the php manual section for the mysqli_real_escape_string() function - http://us.php.net/manual/en/mysqli.real-escape-string.php

 

The procedural style usage requires the link identifier as the first parameter. The second parameter is the string. If you were developing php code and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON, there would have been an error reporting concerning the incorrect parameters that would have probably allowed you to solve at least that part of the problem yourself.

Link to comment
Share on other sites

Modified with mysql instead of mysqli:

 

<?php

//clean XSS/SQL injection
function clean_post($var) {

$var=strip_tags(trim(mysql_real_escape_string($var)));
$var=htmlspecialchars($var,ENT_QUOTES);
return $var;
}

array_walk_recursive($_POST,'clean_post');

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.