HI guys.
I am having trouble with this:
I have a file with 3 functions in it. Identical, but pulling different info. Another script calls these functions separately and formats it to the webpage.
Everything works ok on my main page, but when I go to any other page, I get riddled with errors. Not sure what's going on.
Example: http://www.winfieldvfd.org
Click on "Read More" and you'll see all the errors I get. Usually they follow this syntax:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/winfield/public_html/scripts/includes/sideitems.php on line 9
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/winfield/public_html/scripts/includes/sideitems.php on line 11
Here's my scripts:
3 Functions in 1 script
function news(){
require_once($_SERVER['DOCUMENT_ROOT'].'/scripts/connection.php');
global $dbc;
$query = "SELECT * FROM `main_news` ORDER BY `id` DESC LIMIT 3";
$result = mysql_query($query, $dbc);
if(!mysql_num_rows($result)){
echo '<div class="news-wrap">'."\n".
'<p class="nItem">No news items were found.</p>'."\n".
'</div>'."\n";
}
else{
while($display = mysql_fetch_array($result)){
$id = $display['id'];
$title = $display['Title'];
$short = $display['Intro'];
echo '<div class="news-wrap">'."\n".
'<h3>'.$title.'</h3>'."\n".
'<p class="nItem">'.$short.'<br />'."\n".
'<a href="http://www.winfieldvfd.org/read.php?cat=news&id='.$id.'">Read More...</a></p>'."\n".
'</div>'."\n";
}
}
}
function events(){
require_once($_SERVER['DOCUMENT_ROOT'].'/scripts/connection.php');
global $dbc;
$query = "SELECT * FROM `main_events` ORDER BY `eDate` ASC LIMIT 3";
$result = mysql_query($query, $dbc);
if(!mysql_num_rows($result)){
echo '<div class="news-wrap">'."\n".
'<p class="nItem">No Events were found.</p>'."\n".
'</div>'."\n";
}
else{
while($display = mysql_fetch_array($result)){
$id = $display['id'];
$edate = $display['eDate'];
$title = $display['Title'];
$short = $display['Intro'];
echo '<div class="news-wrap">'."\n".
'<h3>'.$title.'</h3>'."\n".
'<p class="nItem"><i>'.$edate.'</i><br />'.$short.'<br />'."\n".
'<a href="http://www.winfieldvfd.org/read.php?cat=events&id='.$id.'">Read More...</a></p>'."\n".
'</div>';
}
}
}
function majorcalls(){
require_once($_SERVER['DOCUMENT_ROOT'].'/scripts/connection.php');
global $dbc;
$query = "SELECT * FROM `main_majorcalls` ORDER BY `Date` DESC LIMIT 3";
$result = mysql_query($query, $dbc);
if(!mysql_num_rows($result)){
echo '<div class="news-wrap">'."\n".
'<p class="nItem">No Major Calls were found.</p>'."\n".
'</div>'."\n";
}
else{
while($display = mysql_fetch_array($result)){
$id = $display['id'];
$date = $display['Date'];
$title = $display['Title'];
$short = $display['Intro'];
echo '<div class="news-wrap">'."\n".
'<h3>'.$date.' - '.$title.'</h3>'."\n".
'<p class="nItem">'.$short.'<br />'."\n".
'<a href="http://www.winfieldvfd.org/read.php?cat=news&id='.$id.'">Read More...</a></p>'."\n".
'</div>';
}
}
}
Formatting Script
function sidebar(){
require_once($_SERVER['DOCUMENT_ROOT'].'/scripts/includes/sideitems.php');
echo '<div class="news"><h2>News</h2>'."\n";
news();
echo "\n".'</div>'."\n".
'<br>'."\n".
'<div class="news"><h2>Events</h2>'."\n";
events();
echo "\n".'</div>'."\n".
'<br>'."\n".
'<div class="news"><h2>Major Calls</h2>'."\n";
majorcalls();
echo "\n".'</div>'."\n";
}
Page to be Displayed
<div id="content-wrap">
<div id="left-wrap">
<? sidebar(); ?>
</div>
<div class="content">
<? showItem(); ?>
</div>
</div>
Any help you can offer would be greatly appreciated. Thanks.
~Brett