I'm using PHP and MySQL to code up my new site, however difficulties beyond my knowledge or something small I have missed are causing nightmares!
I have used the $_GET function to catch the name of the specified MySQL table in the URL.... For example: index.php?table=home. The code below is what i'm using:
Code: Select all
<?php
if (!$_GET["table"]) {
$_GET["table"] = "home";
}
$content = $_GET["table"];
if (!file_exists($content)) {
$content = "404";
}
?>Code: Select all
<?php
echo '<font face="Verdana, Arial, Helvetica, sans-serif">' . $content .'</font>';
require_once("config/db.php");
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
mysql_select_db($db) or die ("Unable to select database!");
$sql = "select `id`, `context` from $content";
$rslt = mysql_query($sql);
while ($result = mysql_fetch_array($rslt) )
{
$output = wordwrap($result['context'], 100);
echo '<font face="Verdana, Arial, Helvetica, sans-serif">' . $output .'</font>';
}
?>Ignoring the echo $content function the page gives me the "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /wwwroot/...../index.php on line 59" error.
Can anyone point me in the right direction here?
Many thanks,
Jim