mysql_connect is undefined

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

mysql_connect is undefined

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 &#1111;options] &#1111;-f] <file> &#1111;args...]
       php &#1111;options] -r <code> &#1111;args...]
       php &#1111;options] &#1111;-- 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&#1111;=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:~>
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

If i look at http://www.openbsd.org/3.6_packages/i386.html i do see some php4-* packages....
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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).
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply