Page 1 of 1
mysql_connect is undefined
Posted: Thu Jul 07, 2005 1:35 pm
by pickle
Hi everyone.
I've got a script running via command line PHP that says mysql_connect is an undefined function. However , on this same server, I've got PHP pages that access MySQL lots, and don't complain about it not being defined.
My only guess is that somehow the command line PHP has different extensions/stuff loaded than the Apache module.
Has anyone had this problem before? Thanks for any and all help.
Posted: Thu Jul 07, 2005 3:56 pm
by Chris Corbyn
It'll be a php.ini issue. CLI doesn't read php.ini unless you tell it too.
Use the -c flag to point to the php.ini file. (damn I hope i remembered that right)
EDIT |
Code: Select all
d11wtq@w3style:~> php --help
Usage: php їoptions] ї-f] <file> їargs...]
php їoptions] -r <code> їargs...]
php їoptions] ї-- args...]
-a Run interactively
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d fooї=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>.
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-r <code> Run PHP <code> without using script tags <?..?>
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
args... Arguments passed to script. Use -- args when first argument
starts with - or script is read from stdin
d11wtq@w3style:~>
Posted: Thu Jul 07, 2005 4:17 pm
by pickle
Ok, so when I called php without a -q flag, I found that CGI-wise, I'm running PHP 5.0.4.
I'll look into this myself, but if you know off the top of your head: How do I tell my script which PHP to use? Obviously the version installed as an apache module is different from the version running as CGI. Should I assume there'll be a 4.3.10 CGI I could use?
Thanks for your help.
Posted: Thu Jul 07, 2005 4:59 pm
by pickle
Ok, here's the problem. I had installed 4.3.10, but for some reason the 5.0.4 CGI version was plastered all over my server. So, I uninstalled 4.3.10, installed 4.3.8, and everything seems to be working.
Three words: W, T, F
Thanks for your help.
Posted: Thu Jul 07, 2005 5:58 pm
by Chris Corbyn
Is this the same distro you were having strange path problems with?
I wonder if it came with PHP5 ready installed and somehow installing PHP4 screwed it over

Posted: Fri Jul 08, 2005 9:45 am
by pickle
Are you referring to the problems I had with Apache being in a chroot jail? If so then yes, it is the same distro - OpenBSD 3.6.
I didn't personally install or setup the server, but the guy who did set it up says no PHP comes with the distro - he had to install everything. I'm a little suspicious though - I doubt the 5.0.4 CGI came packaged with PHP 4.3.10.
Ah well, it's working now.
Thanks again for your help.
Posted: Fri Jul 08, 2005 11:02 am
by timvw
If i look at
http://www.openbsd.org/3.6_packages/i386.html i do see some php4-* packages....
Posted: Fri Jul 08, 2005 11:34 am
by pickle
Ya I know there are lots - the problem was that the 5.0.4 CGI was installed rather than the 4.3.X CGI - removing 4.3.10 and adding 4.3.8 worked (somehow).