Warning: PDOStatement::execute(): SQLSTATE[HY093]:

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
HSE
Posts: 5
Joined: Fri Nov 16, 2018 5:18 am

Warning: PDOStatement::execute(): SQLSTATE[HY093]:

Post by HSE »

Hi.
After upgrading cacti from 0.8.8h to 1.1.38 (did the upgrade process with the help of this great article - https://www.cacti.net/downloads/docs/html/upgrade.html) the graph tree view is harrassed with this warning message:
Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in /var/www/cacti/lib/database.php on line 262
I am no good in PHP or actually in programming generally, so even though I looked into the file mentioned above, I was left with the bitter taste of defeat.
The odd thing is, that the message disappears while using other accounts. I tried to use different browsers, clear cache, nothing helped.

Thanks.
Last edited by HSE on Mon Dec 10, 2018 10:26 am, edited 1 time in total.
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:

Post by netniV »

There should be a stacktrace next to that error which shows the heirarchy of calls. Do you have that?
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
HSE
Posts: 5
Joined: Fri Nov 16, 2018 5:18 am

Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:

Post by HSE »

netniV wrote:There should be a stacktrace next to that error which shows the heirarchy of calls. Do you have that?
Thank you for your reply.
Is that it?
11/19/2018 11:14:44 - CMDPHP PHP ERROR WARNING Backtrace: (/graph_view.php: 191 top_graph_header)(/lib/functions.php: 3573 include)(/include/top_graph_header.php: 88 grow_dhtml_trees)(/lib/html_tree.php: 117 db_fetch_cell)(/lib/database.php: 234 db_fetch_cell_prepared)(/lib/database.php: 262 execute)(CactiErrorHandler)(/lib/functions.php: 4585 cacti_debug_backtrace)
11/19/2018 11:14:44 - ERROR PHP WARNING: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in file: /var/www/cacti/lib/database.php on line: 262
Last edited by HSE on Mon Dec 10, 2018 10:26 am, edited 1 time in total.
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:

Post by netniV »

Code: Select all

$default_tree_id = db_fetch_cell('SELECT graph_tree.id
        FROM graph_tree
        INNER JOIN user_auth_perms ON user_auth_perms.item_id = graph_tree.id
        AND user_auth_perms.type = 2
        AND user_auth_perms.user_id = ?
        WHERE graph_tree.enabled = "on"
        ORDER BY graph_tree.id
        LIMIT 1',
        array($_SESSION['sess_user_id']));
So, this would appear to be the code that is failing. You should not be receiving the above error as the session should be logged in (ses_user_id is the logged in user). If session isn't set, check that the PHP Session module is actually installed/enabled for your web server.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
HSE
Posts: 5
Joined: Fri Nov 16, 2018 5:18 am

Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:

Post by HSE »

I am running gentoo with PHP 5.6 (which I believe should be supported) and all of the required modules are installed (eg. mysql session sockets xml pcre snmp gd dom)

Not sure if you are familiar with gentoo but this is the PHP package compiled with all the necessary modules:

Code: Select all

# equery u php
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for dev-lang/php-5.6.39:
 U I
...
 + + apache2             : Add Apache2 support
 + + gd                  : Adds support for gd (bundled with PHP)
 + + mysql               : Add mySQL Database support
 + + session             : Add persistent session support
 + + snmp                : Add support for the Simple Network Management Protocol if available
 + + sockets             : Add support for tcp/ip sockets
 + + xml                 : Add support for XML files
...
I followed cacti documentation: https://docs.cacti.net/manual:088:1_ins ... figure_php

The PHP-5.6 is then linked to apache2:

Code: Select all

# eselect php list apache2
  [1]   php5.6 *
I noticed another error (repeated about two hundred times) every time poller (cmd.php) is called via cron:

12/10/2018 15:50:53 - CMDPHP PHP ERROR NOTICE Backtrace: (/clog.php: 39 clog_view_logfile)(/lib/clog_webapi.php: 284 preg_replace_callback)(clog_regex_parser)(/lib/clog_webapi.php: 598 call_user_func_array)(clog_regex_datasource)(/lib/clog_webapi.php: 664 clog_get_datasource_titles)(/lib/clog_webapi.php: 33 get_data_source_title)(/lib/functions.php: 1345 expand_title)(/lib/variables.php: 135 substitute_host_data)(/lib/variables.php: 237 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace)
12/10/2018 15:50:53 - ERROR PHP NOTICE: Undefined index: external_id in file: /var/www/cacti/lib/variables.php on line: 237
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:

Post by netniV »

That error is not actually the poller, but whenever you try to view the logs via Cacti. It is claiming that $external_id is not set, which seems to be causing a problem when attempting to convert one of the matched regex values back to a name. Something isn't quite right with the setup, I'm just can't see yet what it would be.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
HSE
Posts: 5
Joined: Fri Nov 16, 2018 5:18 am

Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:

Post by HSE »

netniV wrote:That error is not actually the poller, but whenever you try to view the logs via Cacti. It is claiming that $external_id is not set, which seems to be causing a problem when attempting to convert one of the matched regex values back to a name. Something isn't quite right with the setup, I'm just can't see yet what it would be.
Where can I set this $external_id if it is some part of a variable which I can set?
And can I deliver some more information to you that could help determine the problem?
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:

Post by netniV »

Do me a favour, in MySQL do a "desc host" for me? I suspect you don't have the external_id column.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
HSE
Posts: 5
Joined: Fri Nov 16, 2018 5:18 am

Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:

Post by HSE »

Code: Select all

MariaDB [cacti]> desc host;
+------------------------+-----------------------+------+-----+---------------------+-----------------------------+
| Field                  | Type                  | Null | Key | Default             | Extra                       |
+------------------------+-----------------------+------+-----+---------------------+-----------------------------+
| id                     | mediumint(8) unsigned | NO   | PRI | NULL                | auto_increment              |
| poller_id              | int(10) unsigned      | NO   | MUL | 1                   |                             |
| site_id                | int(10) unsigned      | NO   | MUL | 1                   |                             |
| host_template_id       | mediumint(8) unsigned | NO   |     | 0                   |                             |
| description            | varchar(150)          | NO   |     |                     |                             |
| hostname               | varchar(100)          | YES  | MUL |                     |                             |
| notes                  | text                  | YES  |     | NULL                |                             |
| external_id            | varchar(40)           | YES  | MUL | NULL                |                             |
| snmp_community         | varchar(100)          | YES  |     | NULL                |                             |
| snmp_version           | tinyint(1) unsigned   | NO   |     | 1                   |                             |
| snmp_username          | varchar(50)           | YES  |     | NULL                |                             |
| snmp_password          | varchar(50)           | YES  |     | NULL                |                             |
| snmp_auth_protocol     | char(6)               | YES  |     |                     |                             |
| snmp_priv_passphrase   | varchar(200)          | YES  |     |                     |                             |
| snmp_priv_protocol     | char(6)               | YES  |     |                     |                             |
| snmp_context           | varchar(64)           | YES  |     |                     |                             |
| snmp_engine_id         | varchar(64)           | YES  |     |                     |                             |
| snmp_port              | mediumint(5) unsigned | NO   |     | 161                 |                             |
| snmp_timeout           | mediumint(8) unsigned | NO   |     | 500                 |                             |
| snmp_sysDescr          | varchar(300)          | NO   |     |                     |                             |
| snmp_sysObjectID       | varchar(128)          | NO   |     |                     |                             |
| snmp_sysUpTimeInstance | int(10) unsigned      | NO   |     | 0                   |                             |
| snmp_sysContact        | varchar(300)          | NO   |     |                     |                             |
| snmp_sysName           | varchar(300)          | NO   |     |                     |                             |
| snmp_sysLocation       | varchar(300)          | NO   |     |                     |                             |
| availability_method    | smallint(5) unsigned  | NO   |     | 2                   |                             |
| ping_method            | smallint(5) unsigned  | YES  |     | 0                   |                             |
| ping_port              | int(12) unsigned      | YES  |     | 0                   |                             |
| ping_timeout           | int(12) unsigned      | YES  |     | 500                 |                             |
| ping_retries           | int(12) unsigned      | YES  |     | 2                   |                             |
| max_oids               | int(12) unsigned      | YES  |     | 10                  |                             |
| device_threads         | tinyint(2) unsigned   | NO   |     | 1                   |                             |
| disabled               | char(2)               | YES  | MUL |                     |                             |
| thold_send_email       | int(10)               | NO   |     | 1                   |                             |
| thold_host_email       | int(10)               | NO   |     | NULL                |                             |
| status                 | tinyint(2)            | NO   | MUL | 0                   |                             |
| status_event_count     | mediumint(8) unsigned | NO   |     | 0                   |                             |
| status_fail_date       | timestamp             | NO   |     | 0000-00-00 00:00:00 |                             |
| status_rec_date        | timestamp             | NO   |     | 0000-00-00 00:00:00 |                             |
| status_last_error      | varchar(255)          | YES  |     | NULL                |                             |
| min_time               | decimal(10,5)         | YES  |     | 9.99999             |                             |
| max_time               | decimal(10,5)         | YES  |     | 0.00000             |                             |
| cur_time               | decimal(10,5)         | YES  |     | 0.00000             |                             |
| avg_time               | decimal(10,5)         | YES  |     | 0.00000             |                             |
| polling_time           | double                | YES  |     | 0                   |                             |
| total_polls            | int(12) unsigned      | YES  |     | 0                   |                             |
| failed_polls           | int(12) unsigned      | YES  |     | 0                   |                             |
| availability           | decimal(8,5)          | NO   |     | 100.00000           |                             |
| last_updated           | timestamp             | NO   |     | CURRENT_TIMESTAMP   | on update CURRENT_TIMESTAMP |
+------------------------+-----------------------+------+-----+---------------------+-----------------------------+
49 rows in set (0.01 sec)
Unfortunately I do...
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:

Post by netniV »

Then something is preventing your from being able to read the data... at least for that host if it's only one host.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests