PHP and MySQL
PHP and MySQL
Can anyone tell me how to get PHP to work with MySQL so that I can set up phpbb ??
If PHP and Apache are working (you can test this by making a php file with <? phpinfo(); ?>), enable the mysql extension in the php.ini file. In php5, mysql is not installed by default, so you have to use the extension. Change the line ";extension=php_mysql.dll" to "extension=php_mysql.dll". Then mysql should work, though that doesn't set up phpbb yet.
Sorry for doubleposting, but I figured this would be more clear as it is an update.
The error message described in my last posting has now dissapeared thanks to some help changing some configuration files that my friend found. Unfortunately, I still can't connect to the database using php. Using the following code:
I get the message: Unable to connect to the database at this time.
Any ideas? Please?
Code: Select all
[i]
[/i]<?php
// *****************************
// ** database server section **
// *****************************
$sqlserver = "localhost";
$sqluserid = "scorpo";
$sqlpassword = "bultiger";
$sqldatabase = "database";
if( !@mysql_connect($sqlserver, $sqluserid, $sqlpassword) ) {
echo("Unable to connect to the database at this time.<br><br>");
exit();
}
if( !@mysql_select_db($sqldatabase) ) {
echo("Unable to locate the database at this time.<br><br>");
exit();
}
$sql = "SHOW TABLES from $sqldatabase";
$resultset = @mysql_query($sql);
if( !$resultset ) {
echo("Unable to run a query at this time.<br><br>");
exit();
}
$row = mysql_fetch_array($resultset);
echo("Looks good! Success!");
?>
PHP's error message from the connect attempt would be more useful than yours, which only tells which line fails. Make sure php is configured to give error details, comment out the if (!@mysql_connect ... exit(); }, and add mysql_connect($sqlserver, $sqluserid, $sqlpassword). Then post the error message you get. Or perhaps get rid of the @ sign.