I would like to read all articles in rows.
Do you know why it gives me error
Warning: link(): Permission denied in ...read_article.php on line 55
Line 55 is:
echo '<td><A HREF="'.link("article.php", "ID=".$_GET['id']).'"><B>'.$rec[$i].'</B></A></td>';
code is:
<?
# Param 1 : MySQL Host Name
# Param 2 : MySQL Username
# Param 3 : MySQL Password
# Param 4 : MySQL Database
# Param 5 : SQL Statement (SELECT)
show_table("localhost","...","...","...","SELECT * FROM articles");
function show_table($hostName,$userName,$passWord,$dataBase,$sqlQuery)
{
# Connect to MySQL
$conn=mysql_connect("...", "...", "...");
# Select Database
mysql_select_db($dataBase,$conn);
# Validate SQL Statement
$array=explode(" ORDER",$sqlQuery);
$sqlQuery=$array[0];
if(!strstr($sqlQuery,"SELECT"))
die("Invalid Query : SQL statement should be a SELECT statement.");
# ORDER records by requested column
if($_GET['order'])
$sqlQuery=$sqlQuery." ORDER BY ".$_GET['order'];
# Execute SQL query
$result=mysql_query($sqlQuery) or die("Invalid Query : ".mysql_error());
$row=mysql_fetch_array($result);
# Check whether NULL records found
if(!mysql_num_rows($result))
die("No records found.");
echo "<table border=1><tr>";
# Make the row for table column names
while (list($key, $value) = each($row))
{
$i++;
if(!($i%2))
echo "<td><b><a href='?order=$key'>$key</a></td>";
}
echo "</tr>";
$result=mysql_query($sqlQuery);
// Make rows for records
while($rec=mysql_fetch_array($result))
{
echo "<tr>";
for($i=0;$i<count($rec);$i++)
{
if($rec[$i])
echo '<td><A HREF="'.link("article.php", "ID=".$_GET['id']).'"><B>'.$rec[$i].'</B></A></td>';
}
echo "</tr>";
}
echo "</table>";
}
?>