Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP-MySQL doesn't work together

Status
Not open for further replies.

axmug

Programmer
Oct 13, 2003
34
ES
I have Apache 1.3.26,PHP 4.2.3, MySQL 3.23.56 installed in a SuSE Linux 8.0 box. I tested Apache, PHP and MySQL separately and run OK. But when I type a PHP scrypt that requires a MySQL connection it doesn't appears anything in the web browser. For example, I typed the following PHP script:

$dbuser="root";
$dbhost="localhost";
$dbpass="pass";
$dbname="test2";
$dbtble="books";

$mysql_link=mysql_connect($dbhost,$dbuser,$dbpass);
$column=mysql_list_fields($dbname,$dbtble,$mysql_link);
for($i=0;$i<=mysql_num_fields($column);$i++)
{
print mysql_field_name($column,$i).&quot;<br>&quot;;
}

After typing it doesn't appears anything in the screen, when in reality must appear all the field names of the table books. I tested this script in my computer and it's OK, but when I tested the same script in the computer of my University it doesn't works. The computer of my University is connected in a network. Is the problem due to the network? I'm always root.

Thanks in advance.
 
It may be that the mysql server is based on a different server to your webserver

MrBelfry
 
Some important things to think about:

1. Don't connect to the server as root through PHP. Create a R/W user that has access to everything but the mysql database (permissions, users etc.).

2. How is PHP setup to connect to the MySQL server? Local socket? Make a script that prints out the phpinfo(); and inspect the MySQL portion for the socket. Make sure the server runs at that socket.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top