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

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

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 :)

    评论

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址