Jump to content


Photo

Need help with a PHP error


  • Please log in to reply
6 replies to this topic

#1 bslevin

bslevin
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 30 July 2006 - 09:49 PM

Hello,

I am very new to PHP and i am having a problem with a script i have. It is a simple "diary / news" script which you enter a subject and body and it displays on the page.

I have moved the script to a test directory becuse it is in a protected members area normally.

the problem i am having is there is an entry posted every week (starting back from the begining of the year) to the present. At the bottom of the page there is a drop down to see past "archived" months. This does not work, if you select a month you get an error in IE - the error is below

Line: 80
Char: 1
Error: Object expected
Code: 0
URL: http://www.kingofthe...m/test/news.php

the link is http://www.kingofthe...m/test/news.php

If anyone has any idea, it would be greatly appreciated, the person who wrote the script cannot be found.

Thanks in advance
Bill

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 30 July 2006 - 10:00 PM

You might want to post some code!

#3 bslevin

bslevin
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 30 July 2006 - 10:03 PM

Sorry about that here is the whole page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title></title>
<link rel=stylesheet type=text/css href="styles.css">

<style type="text/css">

A:link { color:#ffffcc; }
A:visited { color:#ffffcc; }
A:hover { color:red; }
BODY { FONT-SIZE: 12px; FONT-FAMILY: Verdana,Arial,Helvetica,sans-serif;
SCROLLBAR-BASE-COLOR: #492263;
SCROLLBAR-ARROW-COLOR: #ffff66; /*
SCROLLBAR-3DLIGHT-COLOR: #000000;
SCROLLBAR-HIGHLIGHT-COLOR: #FF9999;
SCROLLBAR-SHADOW-COLOR: #FF9999;
SCROLLBAR-DARKSHADOW-COLOR: #660000;
SCROLLBAR-FACE-COLOR: #ffff66;
SCROLLBAR-TRACK-COLOR: #000000;*/
</style>

</head>

<body background="../images/stretch.jpg" bgcolor="Black" leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 text="White" link="#ffffcc" vlink="#ffffcc" alink="#ffffcc">

<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><img src="../images/blank.jpg" width="760" height="16" alt="" border="0"></td>
</tr>
<tr>
<td valign="top">
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#492263">
<tr bgcolor=492263><td align=center><br><strong class=black-large>News and Updates Page</strong><br><br></td></tr>
<tr>
<td><br>
<?
include ("common.php");

MYSQL_CONNECT($hostname,$username,$passwrd) OR DIE("Oh damn! Couldnt connect to the database, sorry mate!");
@mysql_select_db($dbName) or die("<strong class=black-large>Unable to select database</strong>");

if ($month)
{ $sortby = " WHERE $maintable.month='" . $month . "' " ;
$limit = " ";}
else {$sortby = " "; }

$query = "
SELECT $maintable.id, $maintable.thedate, $maintable.topic, $maintable.entry, count($commentstable.id) AS comments
FROM $maintable
LEFT OUTER JOIN $commentstable
ON $maintable.id = $commentstable.id
$sortby
GROUP BY $maintable.id
ORDER BY $maintable.id DESC
$limit";
 
$result = mysql_query($query) or die("<strong class=black-large>Whoops! Something wrong happened to the my database! It would be nice if you emailed <a href=mailto:$webmaster>me</a> and told me!</strong>");

if ($result) {
echo "<table border=0 cellspacing=0 cellpadding=5 width=$width align=center>";
while ($r = mysql_fetch_array($result)) {
extract($r);
$entry = nl2br($entry);
echo " 
<tr bgcolor=492263><td><strong class=black>$topic</strong></td><td align=right><strong class=black>$thedate</strong></td></tr>
<tr bgcolor=492263><td colspan=2><small class=black-small>$entry</small><br></td></tr>
<tr bgcolor=492263><td colspan=2><hr color=ffffff size=1 width=100%></td></tr>
";
}
echo "</table><br>";
mysql_free_result($result);
}


$query2 = "SELECT month FROM $maintable GROUP BY month ORDER BY id";
$result2 = mysql_query($query2) or die("<strong class=black-large>Whoops! Something wrong happened to the my database! It would be nice if you emailed <a href=mailto:$webmaster>me</a> and told me!</strong>");
if ($result2) {
echo "<form><table border=0 cellspacing=0 cellpadding=5 width=$width align=center>
<td align=right colspan=2 valign=top>
<select onchange=\"GoUrl(this)\">
<option> previous news entries for:
<option> &nbsp;";
while ($r2 = mysql_fetch_array($result2)) {
extract($r2);
echo "<option value=news.php?month=$month><strong class=black-small> -&gt; &nbsp; $month </strong>";
}

echo "</select> </td>
</tr></table></form> ";
mysql_free_result($result2);
}


mysql_close();
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><br></td>
</tr>

<tr>
<td></td>
</tr>
</table>



</body>
</html>


#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 30 July 2006 - 10:04 PM

The error states line 80, please narrow it down some. A few lines before and after should suffice.

PS; Also... please use the [ php ] [ / php ] tags (no space).

#5 bslevin

bslevin
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 30 July 2006 - 10:07 PM

Ok here is line 77 - 96

$query2 = "SELECT month FROM $maintable GROUP BY month ORDER BY id";
$result2 = mysql_query($query2) or die("<strong class=black-large>Whoops! Something wrong happened to the my database! It would be nice if you emailed <a href=mailto:$webmaster>me</a> and told me!</strong>");
if ($result2) {
echo "<form><table border=0 cellspacing=0 cellpadding=5 width=$width align=center>
<td align=right colspan=2 valign=top>
<select onchange=\"GoUrl(this)\">
<option> previous news entries for:
<option> &nbsp;";
while ($r2 = mysql_fetch_array($result2)) {
extract($r2);
echo "<option value=news.php?month=$month><strong class=black-small> -&gt; &nbsp; $month </strong>";
}

echo "</select> </td>
</tr></table></form> ";
mysql_free_result($result2);
}


mysql_close();

#6 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 30 July 2006 - 10:10 PM

Actualy... the error you post seems to be a Javascript one, nothing to do with php. Where have you defined the GoUrl() function?

#7 bslevin

bslevin
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 30 July 2006 - 10:17 PM

Actualy... the error you post seems to be a Javascript one, nothing to do with php. Where have you defined the GoUrl() function?


Thank you, i did not notice that, i altered the layout of the script and somehow removed the script that defined the GoUrl() .

thank you so much, this has been driving me crazy!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users