OpenSIPS/opensips-cp

Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number login.php line 186

sunitha-ramki opened this issue · 4 comments

Hi,
I have installed opensips control panel from https://github.com/OpenSIPS/opensips-cp/archive/master.zip
My opensips version is 3.3

When I go to http://192.168.0.103:81/opensips-cp/web/index.php I see the login page.

when I give Username = admin and password = opensips, I get the following error
This page isn’t working192.168.0.103 is currently unable to handle this request.
HTTP ERROR 500

[Sat Dec 24 19:34:41.855373 2022] [php:error] [pid 48] [client 192.168.0.105:61688] PHP Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in /var/www/html/opensips-cp/web/login.php:186\nStack trace:\n#0 /var/www/html/opensips-cp/web/login.php(186): PDOStatement->execute()\n#1 {main}\n thrown in /var/www/html/opensips-cp/web/login.php on line 186, referer: http://192.168.0.103:81/opensips-cp/web/index.php

in login.php
if ($dashboard) {
$query = "SELECT COUNT(*) as panel_no FROM ocp_dashboard;";
$stmt = $link->prepare($query);
if (!$stmt->execute(array($name))) { --->> this is the error line
print_r("Failed to fetch db!");
error_log(print_r($stmt->errorInfo(), true));
die;
}
$resultset = $stmt->fetchAll();
if ($resultset[0]['panel_no'] > 0)
$_SESSION['path'] = "tools/system/dashboard/dashboard.php";
}

can you please let me know whether I am missing something else in my configuration,

If I change the line if (!$stmt->execute(array($name))) { to if (!$stmt->execute()) {

the OpenSIPS Control Panel 9.3.3 window comes up with left side menu User Management, Alias Management, Group Management and System tabs. But no action is possible in User Management if click on it

Sat Dec 24 20:21:35.904913 2022] [php:warn] [pid 11] [client 192.168.0.105:61942] PHP Warning: Undefined array key "db_config" in /var/www/html/opensips-cp/web/common/cfg_comm.php on line 278, referer: http://192.168.0.103:81/opensips-cp/web/main.php
[Sat Dec 24 20:21:35.905127 2022] [php:warn] [pid 11] [client 192.168.0.105:61942] PHP Warning: foreach() argument must be of type array|object, null given in /var/www/html/opensips-cp/web/common/cfg_comm.php on line 278, referer: http://192.168.0.103:81/opensips-cp/web/main.php
[Sat Dec 24 20:21:35.905565 2022] [php:error] [pid 11] [client 192.168.0.105:61942] PHP Fatal error: Uncaught Error: Attempt to assign property "user_management" on null in /var/www/html/opensips-cp/config/tools/users/user_management/settings.inc.php:25\nStack trace:\n#0 /var/www/html/opensips-cp/web/common/cfg_comm.php(222): require()\n#1 /var/www/html/opensips-cp/web/common/cfg_comm.php(388): get_params_from_tool()\n#2 /var/www/html/opensips-cp/web/common/cfg_comm.php(380): session_load_from_tool()\n#3 /var/www/html/opensips-cp/web/tools/users/user_management/template/header.php(31): session_load()\n#4 /var/www/html/opensips-cp/web/tools/users/user_management/user_management.php(25): require('...')\n#5 {main}\n thrown in /var/www/html/opensips-cp/config/tools/users/user_management/settings.inc.php on line 25, referer: http://192.168.0.103:81/opensips-cp/web/main.php
[Sat Dec 24 20:21:36.956590 2022] [php:warn] [pid 10] [client 192.168.0.105:61943] PHP Warning: Undefined array key "db_config" in /var/www/html/opensips-cp/web/common/cfg_comm.php on line 278, referer: http://192.168.0.103:81/opensips-cp/web/menu.php
[Sat Dec 24 20:21:36.956758 2022] [php:warn] [pid 10] [client 192.168.0.105:61943] PHP Warning: foreach() argument must be of type array|object, null given in /var/www/html/opensips-cp/web/common/cfg_comm.php on line 278, referer: http://192.168.0.103:81/opensips-cp/web/menu.php
[Sat Dec 24 20:21:36.957171 2022] [php:error] [pid 10] [client 192.168.0.105:61943] PHP Fatal error: Uncaught Error: Attempt to assign property "user_management" on null in /var/www/html/opensips-cp/config/tools/users/user_management/settings.inc.php:25\nStack trace:\n#0 /var/www/html/opensips-cp/web/common/cfg_comm.php(222): require()\n#1 /var/www/html/opensips-cp/web/common/cfg_comm.php(388): get_params_from_tool()\n#2 /var/www/html/opensips-cp/web/common/cfg_comm.php(380): session_load_from_tool()\n#3 /var/www/html/opensips-cp/web/tools/users/user_management/template/header.php(31): session_load()\n#4 /var/www/html/opensips-cp/web/tools/users/user_management/user_management.php(25): require('...')\n#5 {main}\n thrown in /var/www/html/opensips-cp/config/tools/users/user_management/settings.inc.php on line 25, referer: http://192.168.0.103:81/opensips-cp/web/menu.php

thank you

@sunitha-ramki , that version you were testing at that point was a devel version, so pron to errors. Please try now the 9.3.3 Control Panel version and see if you still have the issue.

That error is showing up in 9.3.3 fresh install PgSQL

2023-04-05 22:05:56 CDT devmaster@10.0.5.25(52320):opensips [3714138] ERROR:  bind message supplies 1 parameters, but prepared statement "pdo_stmt_00000002" requires 0
2023-04-05 22:05:56 CDT devmaster@10.0.5.25(52320):opensips [3714138] STATEMENT:  SELECT COUNT(*) as panel_no FROM ocp_dashboard;

That error is showing up in 9.3.3 fresh install Mysql

PHP Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in /var/www/html/opensips-cp/web/login.php:203\nStack trace:\n#0 /var/www/html/opensips-cp/web/login.php(203): PDOStatement->execute()\n#1 {main}\n thrown in /var/www/html/opensips-cp/web/login.php on line 203, referer: http://172.20.254.93/cp/index.php

Please check the latest version and confirm the fix .