Hi,
I have been playing with PHP for a bit, but have never tried to connect to our mySQL database. I think now I am ready to start this. But I am having trouble. I got this code right from php.net:
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password")
or die("Could not connect: " . mysql_error());
print ("Connected successfully");
mysql_close($link);
?>
Whether the u/p are correct or not all I get when I run the page is
Fatal error: Call to undefined function: mysql_connect() in /blah/php/mysql_connect2.php on line 2
What gives?
Like wise I got this code from the book I am working through:
<?php # Script 6.5 - mysql_connect.php
// This file contains the database access information. This file also establishes a connection to MySQL and selects the database.
// Set the database access information as constants.
DEFINE ('DB_USER', 'mysql_user');
DEFINE ('DB_PASSWORD', 'mysql_password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'sitename');
// Make the connnection and then select the database.
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );
mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() );
?>
No matter if the u/p are correct all I get is a blank screen.
Any help would be greatly appreciated.