I can not find an error in php (It all starts here: http://stackoverflow.com/questions/30393024/)

后端 未结 1 682
甜味超标
甜味超标 2021-01-25 12:48

I can not find an error in php. Sometimes such a error:

Warning: array_walk() expects parameter 2 to be a valid callback, function \'array_sanitize\'

1条回答
  •  粉色の甜心
    2021-01-25 13:01

    Try this:

    function register_user($register_data) {
        global $con;
        array_walk($register_data, 'array_sanitize');
        $register_data['password'] = md5($register_data['password']);
    
        $fields = '`' . implode('`, `', array_keys($register_data)) . '`';
        $data = '\'' . implode('\', \'', $register_data) . '\'';
    
        $insert = "INSERT INTO users($fields) VALUES ($data) ";
        mysqli_query($con,$insert);
        $last_id = mysqli_insert_id($con);
        $update = "UPDATE users SET url = '".$last_id."' WHERE id = ".$last_id." ";
        mysqli_query($con,$update );  
    }
    function aray_sanitize(&$item) { 
        $item = mysql_real_escape_string($item); 
    } 
    

    0 讨论(0)
提交回复
热议问题