Re: mysql_connect won't when run from web server

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
+ (text/plain)
Delete this message
Reply to this message
Author: Lisa Kachold
Date:  
To: Steven A. DuChene, Main PLUG discussion list
Subject: Re: mysql_connect won't when run from web server
Hi Steven,

On Sun, May 24, 2009 at 3:53 PM, Steven A. DuChene <
> wrote:

> Hello all:
> I have a php to mysql database connection script that I am having a problem
> with.
> I have two systems. One is running apache and also happens to be my desktop
> system.
> Call this one system Apache. The other system is running mysql and let's
> call this
> one Mysql.
>
> the connection script is very simple:
>
>    <?php
>    $dbhost = "Mysql";
>    $dbuser = "someuser";
>    $dbpass = "NOTREAL";

>
>    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die("Error
> connecting to mysql");

>
>    if ($conn) {
>    echo "CONNECT OK";
>    }

>
>    $dbname = "tmp";
>    mysql_select_db($dbname);
>    ?>

>
>
> If I run this script from the command line on the Apache system like so:
>
> $ php testmysqlconnect_script.php
>
> and it works fine. However if I run the script from the web browser open on
> the
> Apache desktop and point it at
> http://localhost/~meuser/testmysqlconnect_script.php<http://localhost/%7Emeuser/testmysqlconnect_script.php>
> I get a connection error. Just to confirm I have also used the following
> mysql
> command from the command line on the Apache system and it works fine as
> well:
>
> mysql --host=Mysql -u someuser -p tmp
>
> and entered the exact same user name as is in my script and I am able to
> connect
> just fine. I have tried looking at the output from php_info() on the Apache
> web
> server and it looks normal but I could be missing something.
>
> Anyone have any ideas of what I might be over looking???



1) What is apache saying about this? Tail the logs?
1.5) Change to FQDN like mysql.mylocalnetwork rather than IP or CNAME and
retest script.
2) Verify you have php extensions enabled (can you run other .php files in
apache)?
3) What does tcpdump on each server say? Do you see the connection go out?
Do you have a sniffer that you can invoke and filter specifically between
these two servers? Wireshark?
4) Selectively take down firewalling between each server and test to verify
once you determine it might be switch or router or local iptables causing
the issues?
5) Do you allow scripting from that directory in your Apache <directory>
tags?

>
> --
> Steve DuChene
>


www.obnosis.com (503)754-4452
"Contradictions do not exist." A. Rand
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss