PHP Fatal error: Call to undefined function: mysql_pconnect() 

Today, while I am trying to access the webcalendar from browser, nothing shows up, no error message. why would it suddenly stop functioning? my first instinct is to look for some clue from the log /var/log/httpd/ssl_error_log, ha, I see a PHP Fatal error: "Call to undefined function: mysql_pconnect() in /usr/share/webcalendar/includes/php-dbi.php on line 97" , looks like php failed to connect to mysql database. why it would suddenly failed, since upraded mysql to newer version in the previous upgrade, I haven't done any change to php setup, and it worked fine since the upgrade.
Something happened after the upgrade and I didn't notice? what about restarting mysql? I restarted mysql, no difference. how about restarting httpd, restarted httpd,and I noticed an error "PHP Warning: Unknown(): Unable to load dynamic library '/usr/lib/php4/mysql.so' - libmysqlclient.so.10: cannot open shared object file: No such file or directory in Unknown on line 0", seems Apache does not load php mysql library correctly, ah, I remembered that since the previous mysql upgrade, I symbolic linked the /usr/lib/mysql to my new mysql library /usr/local/mysql/lib/mysql. I deleted the symbolic link, changed it back to my old mysql library and restarted httpd, the error message is gone and the webcalendar worked again. I think while I upgraded the mysql, and linked the new mysql library to /usr/lib/mysql, the apache were still calling the old mysql library from memory, once apache restarted itself when finishing the weekly log rotation, it begins to call the new mysql library and failed to load PHP mysql library. the problem solved, but question still remains: why apache could not load PHP mysql library by calling the new mysql library from /usr/local/mysql/lib/mysql? do I have to recompile PHP with the new mysql library? probably
[ add comment ] permalink ( 3 / 73 )
Search two files with similar content by Perl 

Sometimes I need to compare two similar files and get to know what entry is in file1, what entry is in file2, I have tried read each file and loop through the files line by line and compare the lines with regex, but it turned out to be very dumb idea and I never got it working. After reading more Perl doc and mailling list, apparently, the perl hash variable is the way to define uniqness of a record, here is the perl script I I got it working:

#!/usr/bin/perl
use strict;
use warnings;
use Tie::File;

tie my @array1, 'Tie::File', "/tmp/u1.txt" or die "Could not tie: $!";

tie my @array2, 'Tie::File', "/tmp/u2.txt" or die "Could not tie: $!";

my %index;
foreach my $entry (@array1) {
if (not exists $index{$entry}) {
$index{$entry} = 1;
}
}

foreach my $entry (@array2) {
if (not exists $index{$entry}) {
$index{$entry} = 2;
}
else {
$index{$entry} += 2;
}
}

foreach my $entry (keys %index) {
if ($index{$entry} == 1) {
print "Entry $entry is only in file one\n";
}
elsif ($index{$entry} == 2) {
print "Entry $entry is only in file two\n";
}
elsif ($index{$entry} == 3) {
print "Entry $entry is in both files\n";
}
else {
print "Entry $entry is screwed up!\n";
}
}

[ add comment ] permalink ( 3 / 79 )
A Perl tip to replace strings, symbols.. 

perl -pi'.orig' -e 's/oldstring/newstring/g' fileA, fileB...the i argument is backup option, fileA, fileB will be backed up as fileA.orig, fileB.orig. Ever have format problem with '\r','^M', '\n' after transfering files between windows/mac/linux. try perl -pi'.orig' -e 's/\r(\n)?/\n/g' fileA, fileB...

If on unix/linux, try unix2dos command
[ add comment ] permalink ( 3.1 / 70 )
Wonder how to get two way packets from tcpdump? 

Such a simple question, silly me. run tcpdump on both end and specify the src host and dst port or src port.
[ add comment ] permalink ( 3.1 / 82 )
MySQL setup hassle 

While fiddling with mysql setup, the new mysql command client connect to the new mysql server fine, but not old mysql command client, so I have to make symbolic link to the new mysql command client like ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql, same as mysqladmin...

I thought the above symbolic link should solve all the setup problem, but it didn't. When I run the WebCalendar setup and test mysql conncetion from the web setup interface, error "could not connect /var/lib/mysql/mysql.sock..." pops up, damn! why would the WebCalendar look for the old mysql server socket file instead of the new one /tmp/mysql.sock? is this PHP mysql client problem? To work around this issue, I reset the socket file to /var/lib/mysql/mysql.sock in the mysql client and server section of /etc/my.cnf "socket = /var/lib/mysql/mysql.sock" and restarted msyqld. this sovled the socket problem.
I was so happy to get rid of the complain and test the mysql connection again, but guess what, I came across another problem "Client does not support authentication protocol". I googled around the Internet, found the http://dev.mysql.com/doc/refman/5.0/en/old-client.html link. (pre-4.1) mysql clients does not support the new hash algorithm, well, I don't know how the WebCalendar PHP application call the old mysql client and don't want to update all mysql client libraries. I could reset the WebCalendar mysql user password to pre-4.1 style:

mysql> SET PASSWORD FOR
-> 'webcalendar'@'localhost' = OLD_PASSWORD('newpwd');

I can identify these accounts with the following query:

mysql> SELECT Host, User, Password FROM mysql.user
-> WHERE LENGTH(Password) > 16;

when you

mysql> desc mysql.user;

you will see the pos-4.1 mysql use varchar(41) to define the "Password" colum.

After I reset the Password, all works fine
[ add comment ] permalink ( 2.9 / 80 )

Back Next