Welcome, Guest. Please login or register.

Author Topic: PHP Fatal error - Call to undefined function mysql_connect() after upgrade  (Read 2976 times)

angrybutler

  • Newbie
  • *
  • Posts: 14
    • View Profile
I just upgraded my Ubuntu install to 16.10 (xenial), and nedi 1.4 is now completely hosed.

It appears as if the new Ubuntu version strongly prefers php7.0 and mysql5.7.

Apparently Nedi 1.4 uses deprecated "mysql" functions in  libdb-mysql.php for mysql database access.

php7 appears to have completely abondoned mysql, and instead uses mysqli or mysqlnd functions instead.

I've spent many hours trying to figure out how to re-enable the "mysql" php functions with no joy.

Has anyone else run into this yet?   Is anyone aware of a fix?

Here's the complete error message from the Apache2 error.log:

[Mon Apr 18 17:02:12.461144 2016] [:error] [pid 27162] [client 127.0.0.1:44708] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in /opt/nedi/html/inc/libdb-mysql.php:7\nStack trace:\n#0 /opt/nedi/html/index.php(61): DbConnect('localhost', 'nedi', <****>, 'nedi')\n#1 {main}\n  thrown in /opt/nedi/html/inc/libdb-mysql.php on line 7, referer: http://localhost/index.php?goto=Devices-List.php





rickli

  • Administrator
  • Hero Member
  • *****
  • Posts: 2526
    • View Profile
    • NeDi
Indeed something that's been on my radar too. I've migrated NeDi 1.6 to mysqli now. It created another problem with NeDiO14, where php5-mysqli needs to be installed in order to make NeDi 1.6 work  >:(

Is there any chance you can revert to php5 on xenial for now?
Please consider Other-Invoices on your NeDi installation for an annual contribution, tx!
-Remo

ascii

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
i tired the update on VM a couple month ago.
had the same problem.

from now on debian stretch (Testing tree) pushes PHP 7 as default.
so on debian testing you have to mark php7 with hold if you want to use NeDi

tristanbob

  • Full Member
  • ***
  • Posts: 142
    • View Profile
I just upgraded Ubuntu to 16.04 and it broke just like you described. 

What is the best way around this?  Sounds like we need to get php5 installed again?   

I'll post if I find out how to get this working again.
Please visit "Other"->"Invoices" on your NeDi installation to make an annual contribution and support Nedi!

tristanbob

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Ok, I got things working again by using PHP5.6, which requires using a PPA repository.

Code: [Select]

# This is needed for "apt-get-repository"
sudo apt-get install software-properties-common python-software-properties

# Add the new repo
sudo add-apt-repository ppa:ondrej/php

# Download package lists
sudo apt-get update

# Install Nedi dependencies
sudo apt-get install apache2 libapache2-mod-php5.6 mysql-server libnet-snmp-perl libcrypt-rijndael-perl libcrypt-hcesha-perl libcrypt-des-perl libdigest-hmac-perl libio-pty-perl libnet-telnet-perl libalgorithm-diff-perl librrds-perl php5.6-mysql php5.6-snmp php5.6-gd php5.6-mcrypt rrdtool libsocket6-perl

# I can't remember if this is required, or done by the packages above...
sudo a2enmod php5.6

# Restart Apache
sudo service apache2 restart

That should work for Ubuntu 16.04.  Let me know if I need to correct anything!
Please visit "Other"->"Invoices" on your NeDi installation to make an annual contribution and support Nedi!

harry

  • Full Member
  • ***
  • Posts: 125
    • View Profile
I also have same problem. I can not make ESXi file working from download
Waiting for  out of box working solution with 1.6 to test(with MySqli).....

Hannu Liljemark

  • Full Member
  • ***
  • Posts: 115
  • Here to help
    • View Profile
Uhhuh... basics work great with tristanbob's tips but funky things happen on Ubuntu 16, where both 1.4 and 1.5C are logging weird stuff. All was fine on Ubuntu 12/14.

CISCO887VA-M-K9 device:

DBD::mysql::st execute failed: Out of range value for column 'dinbrc' at row 1 at /var/nedi/inc/libdb.pm line 1342.
DBD::mysql::st execute failed: Out of range value for column 'dinbrc' at row 1 at /var/nedi/inc/libdb.pm line 1342.

Can't reproduce this anymore... maybe just some glitch in the middle of 1.5C update:

DBD::mysql::db do failed: Data too long for column 'device' at row 1 at /var/nedi/inc/libdb.pm line 1849.
DBD::mysql::db do failed: Data too long for column 'device' at row 1 at /var/nedi/inc/libdb.pm line 1849.

Maybe a long name for wlan client pulled from Cisco WLC 5508:

DBD::mysql::db do failed: Data too long for column 'noduser' at row 1 at ./inc/libdb.pm line 2081.
DBD::mysql::db do failed: Data too long for column 'noduser' at row 1 at ./inc/libdb.pm line 2081.

For now I'll just mapip few devices to 0.0.0.0 until I figure this out.

----
Caught one issue with debugging:

EVNT:MOD=1/1 L=200 CL=lnbi TGT=abc-abcd-123456789-abc-gw MSG=Fa0 ABCD has had 23860929 inbound broadcasts/s, exceeds alert threshold of 100/s!
DBG :INSERT INTO events (level,time,source,class,device,info) VALUES (200,1499336259,'abc-abcd-123456789-abc-gw','lnbi','abc-abcd-123456789-abc-gw','Fa0 ABCD has had 23860929 inbound broadcasts/s, exceeds alert threshold of 100/s!')
DBG :INSERTED 1 ROWS
DBD::mysql::st execute failed: Out of range value for column 'dinbrc' at row 1 at /var/nedi/inc/libdb.pm line 1342.
DBD::mysql::st execute failed: Out of range value for column 'dinbrc' at row 1 at /var/nedi/inc/libdb.pm line 1342.

DBG :UPDATE nodes SET lastseen=1499337254,device='AP_AB_CDEF_12',ifname='Do0',vlanid=1,ifchanges=687,metric='SHHSHSHTH',noduser='host/AB-CDE-FGHIJKLM.abcde.efghijkl.fi' WHERE mac='54e1ad07cfb4'
DBD::mysql::db do failed: Data too long for column 'noduser' at row 1 at ./inc/libdb.pm line 2081.
DBD::mysql::db do failed: Data too long for column 'noduser' at row 1 at ./inc/libdb.pm line 2081.

Br,
Hannu
« Last Edit: July 06, 2017, 12:38:02 PM by Hannu Liljemark »

harry

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Please install Mysqli.

Hannu Liljemark

  • Full Member
  • ***
  • Posts: 115
  • Here to help
    • View Profile
Hmm... that's an PHP extension, right? I'm seeing these while doing discovery with nedi.pl.

rickli

  • Administrator
  • Hero Member
  • *****
  • Posts: 2526
    • View Profile
    • NeDi
1. I once thought a int(10) would be enough to hold broadcasts within a discovery. Turns out it isn't! It's initialized with int(20), but older DB's still have int(10).

2. Similarly it can happen that wlan controllers return a very long username like "Remo's MACbook or even more nonsense". Depending on your DB settings it just gets truncated or a screetching halt (your case). I'll be changing libdb.pm line 1867 in 1.7p1 to:

my $user   = $dbh->quote($m->{$dv}{$mcvl}{us}?substr($m->{$dv}{$mcvl}{us},0,30):'');

Limiting to 30 characters to hold escapes characters for singlequotes. Still might need work on ever stranger usernames!
Please consider Other-Invoices on your NeDi installation for an annual contribution, tx!
-Remo

Hannu Liljemark

  • Full Member
  • ***
  • Posts: 115
  • Here to help
    • View Profile
Thanks, Remo! Makes sense.