This is a dup of this thread. Please do not cross post. -- NogDog
I'm using PHP 5.2.5, MySQL 5.0.51b-community-nt and a WinXP machine.
I'm trying to use MySQL using PHP commands, but I can't even get the simplest PHP/MySQL commands
to work. For example here's code from Sams TYS PHP in 24 hours, pg 249:
<?php
$conn = mysql_connect("localhost", "joeuser", "somepass");
echo $conn;
mysql_close($conn);
$user = "p24_user";
$pass = "cwaffie";
$db = "p24";
$link = mysql_connect( "localhost", $user, $pass );
if ( ! $link ) {
die( "Couldn't connect to MySQL: ".mysql_error() );
}
print "<h2>Successfully connected to server</h2>\n\n";
mysql_select_db( $db )
or die ( "Couldn't open $db: ".mysql_error() );
print "Successfully selected database \"$db\"<br />\n";
mysql_close( $link );
?>
I tried running the above code and nothing happens.
I've already tried replacing $pass variable with my password and tried using differenct pathnames to the DB files,
but nothing works.
I've just started learning PHP. Things were fine until I started using MySQL.
I have no problem using MySQL from the command line, but integrating MySQL with PHP has been a problem.
Could the problem be in the php.ini file? I don't know. Maybe someone out here knows.