I'm still getting errors, was wondering if you have the time, could you look at the page I'm working on and see what's up? thanks.
http://www.darwenstheory.net/v2/main.php
Here's the code in the mainfile.php
<?php
//mainfile.php used to house functions for rendering and dynamically allocating data for darwenstheory.net
//1st revision: April 1, 2004 by John W. Shaw II.
// Any modification to this code is very much frowned upon. Do not steal my work.
//Section One - General Variables, Servers, Databases, Logins, and the Like
$host = "localhost"; //hostname of the server
$uname = "u"; //username to access mySQL
$pword = "p"; //password for $uname
$dbase = "darwenst_new"; //database name housing tables and data
$tbl_audio = "audio"; //table containing data for audio
$tbl_video = "video"; //table containing data for video
$tbl_band = "band"; //table containing data about the band members
$tbl_images = "images"; //table containing data about pictures
$tbl_news = "news"; //table containing data about news posts
$tbl_newsletter = "newsletter"; //table containing data about newsletter and its recipients
$tbl_pages = "site_pages"; //table containing data about pages to include based on section
//connect to $dbase. if fails, show error number and error description.
$sql_conn=mysql_connect($host, $user, $pass) or die("MySQL Error #".mysql_errno().": ".mysql_error());
//select the database to work with.
$sql_db=mysql_select_db($dbase);
//if the host, user pass, is incorrect, it wont login.
if(!($link_id = mysql_connect($host, $user, $pass))) die('Sorry, cannot connect to the database. Please note it.');
//Section Two - Functions for News Items
function get_news() {
$SQL = "SELECT COUNT(*) As Total FROM ".$tbl_news."";
$SQL_Result = mysql_db_query($dbase, $SQL);
$SQL_Result_Array = mysql_fetch_array($SQL_Result);
$Total = $SQL_Result_Array['Total'];
$SQL = "SELECT * FROM news ORDER BY news_id DESC";
}
function paginate($pageset) {
if (empty($_GET['count'])) //check the URL for the global variable 'count', if empty...
{
$count=0;
$sql.=" LIMIT $count, $pageset";// ...first page of results, limit the SQL accordingly. otherwise...
}
else
{
$count=$_GET['count'];
$sql.=" LIMIT $count, $pageset"; // ...the results is stored in the global 'count' variable, get only those SQL result-rows
}
$SQL_Result=mysql_db_query($dbase, $sql);
$SQL_Rows=mysql_num_rows($SQL_Result) or die(mysql_errno() . mysql_error());// get new SQL row array based off new SQL query from above
if ($Total > 0) // if the total of the results is more than zero...
{
if ($count < $Total && $count > 0) // ...and if the count is less than total, but more than zero...
{
$Res1=$count-$pageset; // ...subtract actual count from the number of results in a page, and display the link
echo "<a href=\"main.php?page=news&count=$Res1\"><< Previous Page </a> ";
}
$Pages=$Total / $pageset; // get the number of pages by dividing the total of results by how many results per page
if ($Pages > 1) // if there's more than one page...
{
for ($b=0, $c=1; $b < $Pages; $b++, $c++)
{
$Res1 = $pageset * $b;
echo "<a href=\"main.php?page=news&count=$Res1\">$c</a> \n"; //then for each page, display a page number to go to
}
}
if ($count >= 0 && $count<$Total) //but, if the count is greater than or equal to zero, and it is less than total...
{
$Res1=$count + $pageset; // ...add the count and the per page amount...
if ($Res1<$Total)
{
echo "<a href=\"main.php?page=news&count=$Res1\"> Next Page >></a>";// ...but if the result from count + per page amount is less than the total number of results, advance to the next page
}
}
}
}
function makenews() {
for ($a=0; $a < $SQL_Rows; $a++)
{
$SQL_Array=mysql_fetch_array ($SQL_Result);
$news_title=$SQL_Array['news_title'];
$news_auth=$SQL_Array['news_auth'];
$news_date=$SQL_Array['news_date'];
$news_content=$SQL_Array['news_text'];
$news_id=$SQL_Array['news_id'];
$html = "<a name=\"$news_id\"></a><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";
$html .= "<tr bgcolor=\"#CC3300\">";
$html .= "<td colspan=\"2\" align=center style=\"font-color: white;\"><b>$news_title</b></td></tr>";
$html .= "<tr><td width=\"100%\">$news_date • by: $news_auth<br>$news_date</td></tr></table>";
print $html;
}
}
function headlines() {
$SQL2 = "SELECT * FROM ".$tbl_news." ORDER BY news_date DESC LIMIT 5";
$SQL2_Result = mysql_db_query($dbase, $SQL2);
$SQL2_Array = mysql_fetch_array($SQL2_Result);
$SQL2_Rows = mysql_num_rows($SQL2_Result);
for ($x=0; $x < $SQL2_Rows; $x++)
{
$SQL2_Array = mysql_fetch_array($SQL2_Result);
$nhline_id=$SQL2_Array['news_id'];
$nhline_title=$SQL2_Array['news_title'];
$hlinehtml = "<li><a href=\"main.php?page=news#$nhline_id\">$nhline_title</li>";
print $hlinehtml;
}
}
function pickpage($page) {
global $dbase;
global $tbl_pages;
$SQL3 = "SELECT * FROM ".$tbl_pages."";
$SQL3_Result = mysql_db_query($dbase, $SQL3);
$SQL3_Array = mysql_fetch_array($SQL3_Result, MYSQL_ASSOC);
$SQ3_Rows = mysql_num_rows($SQL3_Result);
$ppage = $SQL3_Array['page_link'];
if(!(in_array($page, $SQL3_Array))) {
include ('news.php');
} else { include ($ppage); }
}