[LUNI] Epic LAMP Fail

Richard Lynch ceo at l-i-e.com
Sun Sep 19 16:35:13 CDT 2010


> Fatal error: Call to undefined function mysql_connect() in
> /var/www/HelloLAMP.php on line 8

Translation:
You have NOT, repeat NOT, correctly installed the PHP-mysql extension.
You can confirm what extensions you DO have with:
<?php phpinfo();?>
Every extension you have is listed in its own section, with version
and settings details.
Any section "missing" is, errr, missing, and not there.

NOTE:
If you are using PHP as a MODULE of Apache (most common setup) then
you MUST re-start Apache for it to re-read the php.ini after you
change php.ini to add your mysql.so line.
This is the #1 cause of the above error among otherwise savvy users.

#2 cause is just not installing php-mysql package. :-)

The existence or lack thereof of mysqli package is indeed irrelevant
to the mysql package.  They are two ways to skin the same cat, but
having one does not magically make the other "work" or "fail"

> Fatal error: Call to undefined function mysql_select() in
> /var/www/HelloLAMP.php on line 9

There is no mysql_select function in the PHP/MySQL API.
There is a mysql_select_db function, which might be what should have
been on that line.
Or, perhaps, you finally have MySQL all set up, and are now in the
land of some random PHP code trying to call a function that did not
get loaded by require/include statements, and/or some funky __autoload
setup...
I'd have to see more PHP code to tell how you got here...


While the "function not found" error seems like it ought to know
whether it's a library or not to you, that is rather impractical from
a software design stand-point...

PHP would have to have a list of *ALL* functions in *ALL* libraries
that could possibly exist, including custom home-brew ones, and have
that loaded in even though these libraries aren't actually ON the
syatem, in order to know the difference between a missing extension
function and a missing user-land function...

PHP doesn't really care whether the function comes from a library or
not;  It just needs the function to exist to call it, and will give
the same error if it's not there, no matter where it was supposed to
come from.

On Fri, September 17, 2010 8:06 pm, Clyde Forrester wrote:
> Fortunately for my sanity, I still have a printout of the original
> failure. It says:
>
> Greetings in Several Languages
> Fatal error: Call to undefined function mysql_connect() in
> /var/www/HelloLAMP.php on line 8
>
> It just wasn't understanding where it might find the mysql_connect()
> function.
>
> Then I did a bunch of things. Then the error changed to:
>
> Greetings in Several Languages
> Fatal error: Call to undefined function mysql_select() in
> /var/www/HelloLAMP.php on line 9
>
> Not a whole lot different, and not a very noticeable change. I wasn't
> looking for subtle change. I was looking to fix the "I don't know
> where
> the hell to find your damned function" error. I was looking for the
> error to go away completely. I was blind-sided by subtlety, so I'm not
> sure when it changed.
>
> The first error was caused by a glitch somewhere in the interaction
> between Apache, PHP, and MySQL. Some configuration file, or maybe a
> missing module. There were no extra characters. There were no missing
> characters. Nothing to do with a typo. The editor didn't help. The
> online manual didn't help.
>
> The second error was because the function should be mysql_select_db.
> That was where the problem was a typo on my part. Yes, an industrial
> editor would certainly help, but installing one is another, more
> advanced problem for another day. The sooner, the better, of course.
>
> What I have learned is that an "I can't find your function" error can
> look EXACTLY like a "Hell, I can't even find your library" error. I
> consider this a communication problem, a bug, a defect. The error
> message could be doing a better job of resolving this ambiguity. It
> should be either "Library foo not found" or "Function bar not found in
> library foo".
>
> As for me getting along with allegedly fool-proof systems: I'm that
> improved fool y'all have to worry about. :-)
>
> c4
> --
> Program terminated because y0u 5ux0Rz, n00b. RTFM!
>
> jjirsa at comcast.net wrote:
>> Some editor that would cause underscore characters not to be 1
>> character?  I don't know...something that caused syntax errors but
>> the
>> syntax "looks" correct.
>>
>> If you saw the module information in the phpinfo() text, then the
>> only
>> reason why you would get an error is because you have a typo. Maybe
>> you
>> typed "mysql connect()" or "mysql__connect()"?
>>
>> You don't get along with compilers or interpreters very well, do
>> you? ;-)
>>
>> Eclipse with the PDT is nice for editing code; the color coding will
>> show you any syntax errors.  Searching text in a project is faster
>> than
>> grep at the command line.
> --
> Linux Users Of Northern Illinois (Chicago) - Technical Discussion
> http://luni.org/mailman/listinfo/luni
>


-- 
brain cancer update:
http://richardlynch.blogspot.com/search/label/brain%20tumor
Donate:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE




More information about the LUNI mailing list