Each pageX.php will call "config.php" (which contains username, password, db) without the need to include username, pw, db in each page.php
config.php looks like
Code: Select all
<?php
$con=mysqli_connect("localhost","my_userid","my_password","my_db");
?>
Can anybody offer the correct syntax for page1.php to correctly read the "config.php" parameters? Thanks very much
Code: Select all
<?php
// fetch the userid, password and db connection parameters from config
include ("../admin/config01.php");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$ArticleID = $_GET['ArticleID'] ;
// get the results from the database containing various articles
$result = mysqli_query($con,"SELECT * FROM articles WHERE ArticleID='$ArticleID' ");
while($row = mysqli_fetch_array($result))
{
echo $row['ArticleID'] . " " . $row['Article'];
echo "<br>";
}
mysqli_close($con);
?>