Hi guys,
I regularly use a dbconnect script which is taking up a lot of room on my php scripts.
I've tried taking it out into a dbconnect.php file and using the oldmethod. However, include simply does not want to work for this file!!PHP Code:include('dbconnect.php');
I have put an echo line into my dbconnect.php file as a debug idicator but as such it is not displaying.
Has anyone got any ideas?
index.php:
PHP Code:include('dbconnect.php');
$result = mysql_query("SELECT * FROM $table");
$count=mysql_num_rows($result);
while($i < $count) {
$shortname = mysql_result($result, $i, 2);
$sname = mysql_result($result, $i, 1);
echo '<option value="index.php?page=rallydiary&s=' . $shortname . '&p=1">' . $sname . '</option>';
$i++;
}
my dbconnect.php script:
PHP Code:$host="localhost"; // Host name
$username="..."; // Mysql username
$password="..."; // Mysql password
$db_name="..."; // Database name
$table="sections"; // Table Name
$i = 0;
echo "you are using dbconnect.php";
$con = mysql_connect("$host", "$username", "$password");
if (!$con)
{
die("cannot connect");
};
mysql_select_db("$db_name")or die("cannot select DB");
$result = mysql_query("SELECT * FROM $table");

LinkBack URL
About LinkBacks







Bookmarks