My FIRST php atempt
| From: | David Freedman | Date: | Fri, 18 Feb 2005 07:47:12 +0000 |
| Subject: | My FIRST php atempt | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-208998@lists.php.net to get a copy of this message | ||
I am trying my FIRST php file with an attempt to connect
to my mySql server.
<?php
// Connecting, selecting database
$link = mysql_connect('localhost', 'host', 'my_passqword')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('eatc7402') or die('Could not select database');
// Performing SQL query
$query = 'SELECT * FROM my_table';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
==============================
more code to print results.
.
.
============================
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
?>
The problem is it won't connect to the database. The server IS running. The
host, username,
and password are the exact same thing I use to connect the mySqlAdmin tool
to the database.
Doesn't seem like this should be that difficult. How can I discover why it
doesn't
seem to connect.
David F.