473,327 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

mysql_connect stops via php

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
14 2098
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
>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
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
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
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
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
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
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
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
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
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
Thanks for your help anyway.

-Farhan

Nov 5 '07 #13
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LRW | last post by:
I'm working on some scripts someone else made, and it's littered with repetitive mysql_connect's and mysql_select_db's. For example: // MAKE SURE IT IS A VALID PRODUCT $connection2 =...
10
by: Alvaro G Vicario | last post by:
I need that my script retrieves data from two different databases so I use mysql_connect() to open two connections. I have only one server, user and password, just two different databases....
4
by: Andrew Clark | last post by:
Hello, I am having trouble connecting to my server with mysql_connect(). I can connect via the command line on the server and with phpMyAdmin over our network, but not though mysql_connect()....
2
by: Sugapablo | last post by:
I have a small test script connecting to a MySQL database. It seems to work, unless I try to use the resource link identifier returned by mysql_connect(); This works and returns all the rows in...
19
by: Michael | last post by:
Hi, I'm trying to do something which should be very simple - connect to the MySQL database. Here is the call, followed by the error msg. $conn = mysql_connect("localhost", "root", ""); ...
7
by: avenpace | last post by:
Hi, I got error when using mysql_connect function in my php script. If i set the db host to localhost, it give me that error altough all the user and password that I wrote is true(I can login...
6
by: GD | last post by:
Hi All, I've got MySQL 5.0.21 running on Windows Server 2003, and php running on Apache on a Linux box (Fedora Core 4). Previously when the pages were running on an IIS server the connection...
1
by: hugo | last post by:
Hello people, There is a problem is that mysql_connect() somehow caches last sessions IP and is not using the one which you put into host place. Has anyone made mysql_connect() from php to...
10
by: Martin Sciberras | last post by:
Hi All I am new to PHP and MySQL, so please go easy on me! The following is a simple PHP script to connect to my server. The MySQL service is running. The first echo statement displays, but the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.