By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,394 Members | 1,443 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,394 IT Pros & Developers. It's quick & easy.

mysql_connect stops via php

P: n/a
Hi,

Please divert me if this is not the right group to be posting this
question.

I am a Linux client trying to connect to a mysql windows server via
php, upon hitting the mysql_connect line in my php script, it simply
stops executing. In other words anything or'ed with it, like echo
does not end up in the html source. I'm not entirely sure on the
inner workings of php scripting so I can't explain why echo commands
before the mysql_connect don't show up either. However, they appear
fine when the mysql_connect line is commented out. Is it a parsing
issue?

Command line mysql connection works just fine.

phpinfo() gives correct mysql info.

apace error_log says *** glibc detected *** double free or corruption
(!prev): 0x08132138 ***
[Sun Nov 4 14:18:33 2007] [notice] child pid 2316 exit signal Aborted
(6)
Any ideas of how to go about debugging this much appreciated.

Thanks,
Farhan

Nov 4 '07 #1
Share this Question
Share on Google+
14 Replies


P: n/a
Howz about posting your code?
Apart from that, check the settings in your php.ini file and make sure
that error reporting is turned on:

set

error_reporting = E_ALL

and

display_errors = On

restart the server and run the script again.

Nov 4 '07 #2

P: n/a
>I am a Linux client trying to connect to a mysql windows server via
>php, upon hitting the mysql_connect line in my php script, it simply
stops executing. In other words anything or'ed with it, like echo
does not end up in the html source. I'm not entirely sure on the
inner workings of php scripting so I can't explain why echo commands
before the mysql_connect don't show up either. However, they appear
fine when the mysql_connect line is commented out. Is it a parsing
issue?
Assuming you have PHP running under Apache as a module, PHP has
dumped core. This is a serious error somewhere (in PHP, Apache, or
the MySQL client library, most likely).
>Command line mysql connection works just fine.

phpinfo() gives correct mysql info.

apace error_log says *** glibc detected *** double free or corruption
(!prev): 0x08132138 ***
[Sun Nov 4 14:18:33 2007] [notice] child pid 2316 exit signal Aborted
(6)
You might try isolating what causes the problem (for instance, does it
still blow up if you try using an incorrect password?) but debugging
PHP isn't going to be easy if you aren't familiar with PHP source code.

Perhaps you could try reinstalling PHP, all the extensions, and the MySQL
client library.
Nov 4 '07 #3

P: n/a
On Nov 4, 8:05 pm, macca <ptmcna...@googlemail.comwrote:
Howz about posting your code?

Apart from that, check the settings in your php.ini file and make sure
that error reporting is turned on:

set

error_reporting = E_ALL

and

display_errors = On

restart the server and run the script again.
Here it is:

<?php
$username = "root";
$password = "budget";
$database = "budget";

echo "foobar1";

$link = mysql_connect("192.168.1.100", $username, $password);

echo "foobar2";

if (!$link) {
die('Could not connect: ' . mysql_error());
}

echo 'Connected successfully';
?>

HTML that is generated with this script is completely blank. Thanks
for the display_errors = on tip, it is reporting errors (for other
scripts) but nothing new for this one.

Thanks again,
Farhan

Nov 4 '07 #4

P: n/a
farhan wrote:
On Nov 4, 8:05 pm, macca <ptmcna...@googlemail.comwrote:
>Howz about posting your code?

Apart from that, check the settings in your php.ini file and make sure
that error reporting is turned on:

set

error_reporting = E_ALL

and

display_errors = On

restart the server and run the script again.

Here it is:

<?php
$username = "root";
$password = "budget";
$database = "budget";

echo "foobar1";

$link = mysql_connect("192.168.1.100", $username, $password);

echo "foobar2";

if (!$link) {
die('Could not connect: ' . mysql_error());
}

echo 'Connected successfully';
?>

HTML that is generated with this script is completely blank. Thanks
for the display_errors = on tip, it is reporting errors (for other
scripts) but nothing new for this one.

Thanks again,
Farhan

How long did you wait? If, for instance, the mysql_connect() takes a
long time to time out, you could be waiting for a while. And since by
default everything will be buffered, the echo "foobar1"; wouldn't be
seen, either.

Is the mysql server available on your intranet at that address? And is
MySql running?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Nov 4 '07 #5

P: n/a
Hi Jerry,

I'm not sure how to control the length of time to wait other than the
timeout value for mysql.connect which phpinfo() says is 60 seconds.
Firefox seems to try for about 5 seconds (you know the browser wait
thingy) before giving up. The MySql server seems to be fine as I can
connect to it at that address and username/password via the command
line.

On a related note, I did forget to mention a bit of history. To start
with my Linux installation contained MySql 4.x but when installing on
Windows, I used 5.1. So consequently when I tried to connect from the
4.x client to the 5.1 server, it said something about not being about
to authenticate, so I downloaded 5.0 on linux and everything worked
fine on the command line. However, phpinfo() still reported the MySQL
client as 4.x. Not finding any installation scripts, I manually
copied all executables to /usr/bin and all libraries to /lib. Now
phpinfo is correct.

BTW, my php version is 4.3.10.

-Farhan

Nov 5 '07 #6

P: n/a
farhan wrote:
Hi Jerry,

I'm not sure how to control the length of time to wait other than the
timeout value for mysql.connect which phpinfo() says is 60 seconds.
Firefox seems to try for about 5 seconds (you know the browser wait
thingy) before giving up. The MySql server seems to be fine as I can
connect to it at that address and username/password via the command
line.
But can you do it from a command line on your web server? That is, are
you running your web server on your local machine, or is it on another
one? And if it is another server, can you connect to the MySQL database
from the command line there?
On a related note, I did forget to mention a bit of history. To start
with my Linux installation contained MySql 4.x but when installing on
Windows, I used 5.1. So consequently when I tried to connect from the
4.x client to the 5.1 server, it said something about not being about
to authenticate, so I downloaded 5.0 on linux and everything worked
fine on the command line. However, phpinfo() still reported the MySQL
client as 4.x. Not finding any installation scripts, I manually
copied all executables to /usr/bin and all libraries to /lib. Now
phpinfo is correct.

BTW, my php version is 4.3.10.
IOW you could still have mixed file versions - some from 4.x and some
from 5.1. That doesn't sound good.

What happens if you try to connect with an invalid userid/password
and/or to an invalid system?

-Farhan



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Nov 5 '07 #7

P: n/a
But can you do it from a command line on your web server? That is, are
you running your web server on your local machine, or is it on another
one? And if it is another server, can you connect to the MySQL database
from the command line there?
I don't know how to use the command line of the web server - just via
the browser. Yes, the web server is running on my local machine. When
I say command line, I mean the mysql executable which I believe is a
different binary to the one the web server uses. Connecting from the
web server on which the MySQL server is running poses no problems.
IOW you could still have mixed file versions - some from 4.x and some
from 5.1. That doesn't sound good.
Yes, this is possible, but I don't know what other associated files
there are besides the ones in /lib and /usr/bin.
What happens if you try to connect with an invalid userid/password
and/or to an invalid system?
If the syntax is wrong, then I get a parser error in the apache logs.
When using wrong parameters, then the result is the same as my
original.

-Farhan

Nov 5 '07 #8

P: n/a
But can you do it from a command line on your web server? That is, are
you running your web server on your local machine, or is it on another
one? And if it is another server, can you connect to the MySQL database
from the command line there?
I don't know how to use the command line of the web server - just via
the browser. Yes, the web server is running on my local machine. When
I say command line, I mean the mysql executable which I believe is a
different binary to the one the web server uses. Connecting from the
web server on which the MySQL server is running poses no problems.
IOW you could still have mixed file versions - some from 4.x and some
from 5.1. That doesn't sound good.
Yes, this is possible, but I don't know what other associated files
there are besides the ones in /lib and /usr/bin.
What happens if you try to connect with an invalid userid/password
and/or to an invalid system?
If the syntax is wrong, then I get a parser error in the apache logs.
When using wrong parameters, then the result is the same as my
original.

-Farhan

Nov 5 '07 #9

P: n/a
But can you do it from a command line on your web server? That is, are
you running your web server on your local machine, or is it on another
one? And if it is another server, can you connect to the MySQL database
from the command line there?
I don't know how to use the command line of the web server - just via
the browser. Yes, the web server is running on my local machine. When
I say command line, I mean the mysql executable which I believe is a
different binary to the one the web server uses. Connecting from the
web server on which the MySQL server is running poses no problems.
IOW you could still have mixed file versions - some from 4.x and some
from 5.1. That doesn't sound good.
Yes, this is possible, but I don't know what other associated files
there are besides the ones in /lib and /usr/bin.
What happens if you try to connect with an invalid userid/password
and/or to an invalid system?
If the syntax is wrong, then I get a parser error in the apache logs.
When using wrong parameters, then the result is the same as my
original.

-Farhan

Nov 5 '07 #10

P: n/a
But can you do it from a command line on your web server? That is, are
you running your web server on your local machine, or is it on another
one? And if it is another server, can you connect to the MySQL database
from the command line there?
I don't know how to use the command line of the web server - just via
the browser. Yes, the web server is running on my local machine. When
I say command line, I mean the mysql executable which I believe is a
different binary to the one the web server uses. Connecting from the
web server on which the MySQL server is running poses no problems.
IOW you could still have mixed file versions - some from 4.x and some
from 5.1. That doesn't sound good.
Yes, this is possible, but I don't know what other associated files
there are besides the ones in /lib and /usr/bin.
What happens if you try to connect with an invalid userid/password
and/or to an invalid system?
If the syntax is wrong, then I get a parser error in the apache logs.
When using wrong parameters, then the result is the same as my
original.

-Farhan

Nov 5 '07 #11

P: n/a
farhan wrote:
>But can you do it from a command line on your web server? That is, are
you running your web server on your local machine, or is it on another
one? And if it is another server, can you connect to the MySQL database
from the command line there?

I don't know how to use the command line of the web server - just via
the browser. Yes, the web server is running on my local machine. When
I say command line, I mean the mysql executable which I believe is a
different binary to the one the web server uses. Connecting from the
web server on which the MySQL server is running poses no problems.
>IOW you could still have mixed file versions - some from 4.x and some
from 5.1. That doesn't sound good.

Yes, this is possible, but I don't know what other associated files
there are besides the ones in /lib and /usr/bin.
>What happens if you try to connect with an invalid userid/password
and/or to an invalid system?

If the syntax is wrong, then I get a parser error in the apache logs.
When using wrong parameters, then the result is the same as my
original.

-Farhan

When I asked if you could run the command line version from your web
server, I meant the machine your web server is running on - in this case
your localhost. Just trying to ensure you can access the server properly.

But if you get a problem with a double free or similar error during
runtime, it really looks like you've got multiple copies of MySQL on
your system.

And I don't know which Linux you have or how MySQL was originally
installed, so I'd have no idea where else you might have some MySQL
files. But this is the wrong newsgroup for that end, anyway - you need
comp.databases.mysql to follow up on the MySQL end.

And I think right now that's what it seems you need. I don't see any
PHP problem here right now, at least. But lots of possibilities for
MySQL problems.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Nov 5 '07 #12

P: n/a
Thanks for your help anyway.

-Farhan

Nov 5 '07 #13

P: n/a
Greetings, farhan.
In reply to Your message dated Monday, November 5, 2007, 01:02:00,
<?php
$username = "root";
$password = "budget";
$database = "budget";
Do. Not. Use. ROOT. User. In. Production. Environment.
Ever.

All SUPER users in MySQL handled with special rules, different from normal
users.
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Nov 6 '07 #14

P: n/a
On Nov 6, 3:40 pm, AnrDaemon <anrdae...@freemail.ruwrote:
Greetings, farhan.
In reply to Your message dated Monday, November 5, 2007, 01:02:00,
<?php
$username = "root";
$password = "budget";
$database = "budget";

Do. Not. Use. ROOT. User. In. Production. Environment.
Ever.

All SUPER users in MySQL handled with special rules, different from normal
users.

--
Sincerely Yours, AnrDaemon <anrdae...@freemail.ru>
Yes, thank you for pointing this out, however, since this is just a
one of database strictly for home use, I figured it would be okay.

BTW, my problem was fixed by building and installing php5. I'm not
sure if upgrading to 5 fixed the problem or the fact that the building
process linked against the new libmysqlclient.so binary that I dropped
in. I would've expected the dynamic-linker to take care of this for
php4 unless it was not compatible. Either way, I'm out of the woods,
thanks to all.

-Farhan

Nov 7 '07 #15

This discussion thread is closed

Replies have been disabled for this discussion.