473,395 Members | 1,987 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,395 software developers and data experts.

How to Connect to remote MySQL database

Hello PHP group,

I have mysql running on a linux box. I have apache (2.0.4) running on a
diff linux box. I have php 4.X. I can connect to the mysql db using
odbc from a windows box, but cannot connect to the remote db from web
server box (linux) to mysql database (another linux box).
Apache is on RH Enterprise 3.0, mysql is on slacware (2.4.22 kernel).
I am using php, require_once('DB.php'),
and the dsn style connect string: "mysql://username:password@dbhost/test"

Always get an error :"unknown database"

How do I verify that my php is set for mysql?
and any ideas on why I cannot connect? PHP and Apache were the product
as it came with RH Enterprise 3.0ES. I have made no changes to PHP or
APACHE. Maybe I need to?

Thanks Again for the help i have received in the past from this group.

eric w. holzapfel

Jul 17 '05 #1
6 6463
Eric W. Holzapfel wrote:
and the dsn style connect string: "mysql://username:password@dbhost/test"

Always get an error :"unknown database"


Is that the full extent of the error message?

If you run a script like that shown below from the command line (i.e.
via php -f ) on the Linux system running PHP, what sort of output do you
get? Make sure you substitute the appropriate values for USERNAME,
PASSWORD, HOSTNAME, and DBNAME.

<?php

require_once( 'DB.php' );

$dsn = "mysql://USERNAME:PASSWORD@HOSTNAME/DBNAME";

$db_conn = DB::connect( $dsn );

if ( DB::isError( $db_conn ) ) {
print $db_conn->getDebugInfo( ) . "\n";

exit( 1 );
}
else {
print "Connected to database\n";
}

$db_conn->disconnect( );

?>

Lukas

Jul 17 '05 #2
Lukas Neuburger wrote:
Eric W. Holzapfel wrote:
and the dsn style connect string: "mysql://username:password@dbhost/test"

Always get an error :"unknown database"


Is that the full extent of the error message?

If you run a script like that shown below from the command line (i.e.
via php -f ) on the Linux system running PHP, what sort of output do you
get? Make sure you substitute the appropriate values for USERNAME,
PASSWORD, HOSTNAME, and DBNAME.

<?php

require_once( 'DB.php' );

$dsn = "mysql://USERNAME:PASSWORD@HOSTNAME/DBNAME";

$db_conn = DB::connect( $dsn );

if ( DB::isError( $db_conn ) ) {
print $db_conn->getDebugInfo( ) . "\n";

exit( 1 );
}
else {
print "Connected to database\n";
}

$db_conn->disconnect( );

?>

Lukas

Hello PHP and Lukas,

It looks like I lose! I ran the above as "test.php" using php -f
test.php from the command line and got the following as output!
mysql://eric:dumbone@ewhslack/phpbook

What I got was the "echo" of the value for $dsn.
I will be checking my mysql on the slackware box, while I wait for a
reply from newsgroup!

Thanks,

eric

Jul 17 '05 #3
Eric W. Holzapfel wrote:
Lukas Neuburger wrote:
Eric W. Holzapfel wrote:
and the dsn style connect string:
"mysql://username:password@dbhost/test"

Always get an error :"unknown database"


Is that the full extent of the error message?

If you run a script like that shown below from the command line (i.e.
via php -f ) on the Linux system running PHP, what sort of output do
you get? Make sure you substitute the appropriate values for USERNAME,
PASSWORD, HOSTNAME, and DBNAME.

<?php

require_once( 'DB.php' );

$dsn = "mysql://USERNAME:PASSWORD@HOSTNAME/DBNAME";

$db_conn = DB::connect( $dsn );

if ( DB::isError( $db_conn ) ) {
print $db_conn->getDebugInfo( ) . "\n";

exit( 1 );
}
else {
print "Connected to database\n";
}

$db_conn->disconnect( );

?>

Lukas

Hello PHP and Lukas,

It looks like I lose! I ran the above as "test.php" using php -f
test.php from the command line and got the following as output!
mysql://eric:dumbone@ewhslack/phpbook

What I got was the "echo" of the value for $dsn.
I will be checking my mysql on the slackware box, while I wait for a
reply from newsgroup!

Thanks,

eric

Yes, sadly it prints the $dsn variable only, no other info, nothing
comes out of the getDebugInfo( ) command. Could this command be wrong
for my version of php? I have php 4.3.2, I notice the php info in dbx
show mysql odbc, does this mean I may need to recompile php for mysql?
Thanks,

eric

Jul 17 '05 #4
Eric W. Holzapfel wrote:
Yes, sadly it prints the $dsn variable only, no other info, nothing
comes out of the getDebugInfo( ) command. Could this command be wrong
for my version of php? I have php 4.3.2, I notice the php info in dbx
show mysql odbc, does this mean I may need to recompile php for mysql?
Thanks,


The getDebugInfo call is part of the the PEAR DB module, and should work
as long as DB is present and loaded. As to whether or not MySQL
support is enabled under PHP, the following commands should help answer
that:

1. php -i | grep -i mysql

2. php -m | grep -i mysql

These commands will tell you all about the level of MySQL support
available in your build of PHP. Try these commands out on your web
server system.

You will also find the following two links useful:

http://www.php.net/manual/en/ref.mysql.php
http://www.php.net/manual/en/ref.mysqli.php

These links not only discuss MySQL support in PHP, but also how to
enable MySQL support if you need to build your own copy of PHP.

Lukas
Jul 17 '05 #5
Lukas Neuburger wrote:
Eric W. Holzapfel wrote:
Yes, sadly it prints the $dsn variable only, no other info, nothing
comes out of the getDebugInfo( ) command. Could this command be wrong
for my version of php? I have php 4.3.2, I notice the php info in dbx
show mysql odbc, does this mean I may need to recompile php for mysql?
Thanks,

The getDebugInfo call is part of the the PEAR DB module, and should work
as long as DB is present and loaded. As to whether or not MySQL support
is enabled under PHP, the following commands should help answer that:

1. php -i | grep -i mysql

2. php -m | grep -i mysql

These commands will tell you all about the level of MySQL support
available in your build of PHP. Try these commands out on your web
server system.

You will also find the following two links useful:

http://www.php.net/manual/en/ref.mysql.php
http://www.php.net/manual/en/ref.mysqli.php

These links not only discuss MySQL support in PHP, but also how to
enable MySQL support if you need to build your own copy of PHP.

Lukas

Hello Lukas,

Thanks for the info. I get quite a lot on the php -i | grep -i mysql
command. I get nothing for the php -m | grep -i mysql command -
(modules) I do get a ref to pear in the php -i area, a ref to mysql
shared. I will check the links, Thanks again

eric

Jul 17 '05 #6
Hello Lukas et al,

Finally got it going. the modules, and other stuff was missing.
finally got the right pieces installed, etc.

Thanks for the help and info,

eric

Lukas Neuburger wrote:
Eric W. Holzapfel wrote:
and the dsn style connect string: "mysql://username:password@dbhost/test"

Always get an error :"unknown database"


Is that the full extent of the error message?

If you run a script like that shown below from the command line (i.e.
via php -f ) on the Linux system running PHP, what sort of output do you
get? Make sure you substitute the appropriate values for USERNAME,
PASSWORD, HOSTNAME, and DBNAME.

<?php

require_once( 'DB.php' );

$dsn = "mysql://USERNAME:PASSWORD@HOSTNAME/DBNAME";

$db_conn = DB::connect( $dsn );

if ( DB::isError( $db_conn ) ) {
print $db_conn->getDebugInfo( ) . "\n";

exit( 1 );
}
else {
print "Connected to database\n";
}

$db_conn->disconnect( );

?>

Lukas


Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ryan Stewart | last post by:
I'm running MySQL server on a WinXP box at home. I have a cable modem/router. I've set up port forwarding on port 3306 to the machine running MySQL. I can connect locally just fine, but when I try...
1
by: jose | last post by:
Hello. I have mysql working. I have change my hostname name(until now i used localhost) and i cannot connect. # mysql -u mail -p -h server.domain.com Enter password: ERROR 1130: Host...
16
by: MLH | last post by:
Using MS Access, I have attached to MySQL servers in other states and other countries on the other side of my router. But when I use the MySQL ODBC driver 3.51 to connect to a MySQL server on my...
3
by: Steven | last post by:
Hi All, I've installed MySQL 4.1.12 on my server, I can connect from the local machine with navicat, but not from a remote machine. I checked with 'nedstat' and there is something listening on...
4
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to...
5
by: smatta | last post by:
I have just installed MySql version 5.0-18 on Red Hat Fedora Core 4. It is running but I cant connect to it using MySql Query Browser running on my pc. >From my pc, I can telnet to the sql...
4
by: courtney.machi | last post by:
Hello, I am trying to connect to a remote mysql server through php. Here's the code: mysql_connect("my.hostname.edu", "username", "password") or die (mysql_error());...
2
by: Martin | last post by:
Hi all. I have a fully functional page hosted on my PC that uses PHP and connects to MySQL on my PC to generate it's code. I now have some web hosting available which includes both PHP and...
1
by: jmohan | last post by:
Dear Sir/Madam, I develop a website in asp.net with c#. And also, I develop a toolbar in the toolbar studio separately. Aim of the Website: Enabling the visitors to become a member of our...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.