Jump to content

Recommended Posts

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.kingoftheheel.com/test/news.php

the link is http://www.kingoftheheel.com/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
Link to comment
https://forums.phpfreaks.com/topic/16053-need-help-with-a-php-error/
Share on other sites

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>
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();
[quote author=thorpe link=topic=102372.msg406202#msg406202 date=1154297412]
Actualy... the error you post seems to be a Javascript one, nothing to do with php. Where have you defined the GoUrl() function?
[/quote]

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!!
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.