doumi7854 2015-05-05 18:19
浏览 65

函数名称必须是字符串错误

Im getting this error

Fatal error: Function name must be a string in /home/an011500/www_root/nastavenia.php on line 32

Can you help me fix this?

EDIT: Whole code

php_functions.php file

 <?php


  function check_username($user_name)
    {
    require('PDO_DB_connect.php');
    $sql_query1= "SELECT username FROM user WHERE username=:username";
    $query1 = dbConnect()->prepare($sql_query1);
    $query1->bindParam(':username', $user_name);
    $query1->execute();
    if($query1->rowCount() == 0)
    {
        return true;
    }
    else
    {
        return false;
    }
    }
    ?>

nastavenia.php file

    <?php
session_start();
if(isset($_SESSION['username']))
{
    $session_set = true; 
}
elseif(!isset($_SESSION['username']))
{
    header("location: index.php");
    $session_not_set = true;
}

require('PDO_DB_connect.php');
require('php_functions.php');

$user_name = osetri_string($_POST['username']);
$email = osetri_string($_POST['email']);
$password = osetri_string($_POST['password']);
$confirm_password = osetri_string($_POST['password1']);
$actual_password = osetri_string($_POST['actual_password']);


if(isset($_POST['submit']))
{
    if(isset($_POST['actual_password']))
    {
        if(check_username($user_name) === true)
        {
           if(isset($_POST['username_radio_button']))
            {
            $prepared_username_sql_query = "UPDATE user SET username=:username WHERE username=:actual_username AND password=:actual_password";
            $username_sql_query($prepared_username_sql_query);
            $username_sql_query->bindParam('username' ,$user_name);
            $username_sql_query->bindParam('actual_username' ,$_SESSION['username']);
            $username_sql_query->bindParam('actual_password' ,$actual_password );
            if($username_sql_query->execute())
               {
                $user_info = "not a fail?";
               }
            }
        }
        else
        {
            $username_error = "fail";
        }
    }
}

?>

My post is mostly code? Fine. XXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • 写回答

3条回答 默认 最新

  • duangangmo0583 2015-05-05 19:03
    关注

    You are attempting to call the function name stored in $username_sql_query here...

    $username_sql_query($prepared_username_sql_query);
    

    But on the very next line, you refer to that same variable as an object...

    $username_sql_query->bindParam('username' ,$user_name);
    

    If $username_sql_query is an object, then that first line should probably also be a method call.

    I would also give some meta-advice here - you posted a lot of code when PHP was telling you exactly which line was at fault. If you studied that one line, and perhaps dumped the variables to see if they contained what you expected, you would have solved this in less time than it's taken me to write this paragraph :)

    评论

报告相同问题?