I have downloaded and installed PHP successfully on my PC running Windows NT using the Windows installer version rather than compiling source. The basic PHP commands seem to be working. However MySQL does not seem to be working from within PHP...
The symptoms are that the mysql_connect( ) and mysql_select_db( ) are completing OK but actual SQL done via mysql_query( ) is returning false result (no error though).
I downloaded MySQL separately and can run mysqladmin and the DOS interface where I can create tables and query them.
I notice in the PHP documentation that from PHP4 has MySQL "built into PHP". There are also comments about having to tell PHP where the MySQL implementation is if you do not want to use the built in version. But how do you do this? I can't work out where to put the directive to tell PHP to use MySQL in the c:/mysql directory or even if I need to do this...
Help! Anyone got any ideas/answers?
Configuring MySQL in PHP
Moderator: General Moderators
Example of SQL failing
As requested here is an example of the PHP code that is not working. It prints allthe connection stuff but then prints the "No MySQL result"
Could it be an authority issue? How do I look at the MySQL settings for the default PHP MySQL settings?
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Do MySQL 2</title>
</head>
<body>
<?PHP
$DB_HOST = "localhost";
$DB_USER = "root";
$DB_PASSWORD = "fenton";
$db_link = mysql_connect( $DB_HOST, $DB_USER, $DB_PASSWORD ) or die("cannot connect to MySQL");
print("Connected to MySQL
");
$DB_NAME = "mysql";
mysql_select_db($DB_NAME, $db_link) or die("cannot select 'mysql' database");
print("<br>'mysql' selected");
$sqlstring = "CREATE TABLE test (test_id smallint(6) DEFAULT '0' NOT NULL auto_increment, test_text tinytext NOT NULL, PRIMARY KEY (test_id))";
$result = mysql_query( $sqlstring, $db_link );
if ( $result ) {
print("<br>MySQL instruction executed:<br>$sqlstring");
} else {
print("<br>No MySQL result... <br>$sqlstring
");
}
?>
</body>
</html>Also, why not use the command line interface to add tables and stuff? Or even better than that, get the glorious phpMyAdmin:
http://www.phpwizard.net/projects/phpMyAdmin/index.html
http://phpmyadmin.sourceforge.net/
http://www.phpmyadmin.net/
http://www.phpwizard.net/projects/phpMyAdmin/index.html
http://phpmyadmin.sourceforge.net/
http://www.phpmyadmin.net/