PHP and MySQL
-
Scorpo
- Registered User
- Posts: 26
- Joined: June 28th, 2005, 2:38 am
PHP and MySQL
Can anyone tell me how to get PHP to work with MySQL so that I can set up phpbb ??
-
Smartweb
- Registered User
- Posts: 622
- Joined: January 15th, 2004, 2:11 am
-
Scorpo
- Registered User
- Posts: 26
- Joined: June 28th, 2005, 2:38 am
-
Smartweb
- Registered User
- Posts: 622
- Joined: January 15th, 2004, 2:11 am
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.
-
Scorpo
- Registered User
- Posts: 26
- Joined: June 28th, 2005, 2:38 am
-
Scorpo
- Registered User
- Posts: 26
- Joined: June 28th, 2005, 2:38 am
-
Scorpo
- Registered User
- Posts: 26
- Joined: June 28th, 2005, 2:38 am
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!");
?>
-
Smartweb
- Registered User
- Posts: 622
- Joined: January 15th, 2004, 2:11 am
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.