Page 1 of 2

Help with viewing blog entrys via archive page..

Posted: Thu Apr 01, 2004 7:48 pm
by seeker2921
I've been trying to create an archive page with little luck.. I think I'm going in the right direction but i'm stuck.. The page does what it needs to up until I tell it to get a single blog entry then I get this:

Fatal error: Maximum execution time of 30 seconds exceeded in /home/stephen/public_html/site/blog/archives.php on line 54

So I'm guessing my loop doesn't stop? Line 54 is where I start the loop..

Code: Select all

<? 
if(!isset($entry)){
echo'<ul>';
//Get config file
include("/home/stephen/site/inculdes/config.php"); 


/* Connecting to MySQL*/ 
    $connection = mysql_connect($db_host,$db_user,$db_pass) 
        or die("Could not connect to mysql. Fix me!?!"); 
      
        /* Select Database. */ 
     $db = mysql_select_db($database_name,$connection) or die("ERROR: I couldn't select the database requested!"); 

//Time choices 
if ($UStime==we_are_superior) { 
//date format 
    $sql = "SELECT DATE_FORMAT(date, '%M %e, %Y @ %h:%i %p') AS readable_date,topic,entry,ID FROM $tablename order by date desc"; 
   $sql_result = mysql_query($sql, $connection) or die("Query failed. Please contact the site administrator, and bitch at him."); 

/*setting up array and defining result values */ 
     while ($row = mysql_fetch_array($sql_result)) {  

//defining variables, readable_date is temp field  
$date = $row["readable_date"]; //date 
$topic = $row["topic"]; //Title of blog entry 
$id = $row["ID"]; //ID of blog entry 
$post = $row["entry"];
$Post = nl2br($post); //

//HTML for post
$view = ("<table cellspacing='0' cellpadding='0' border='0'>
<tr>
<td width='150' align='left' valign='top' style='padding: 5px'>
<img src='/site/images/bullet.gif' align='left'><i><b>$topic</b></i><br>
<font size='1'><i>$date</i></font>
</td>
<td width='500' bgcolor=000000 align='left' valign='top' style='border-top: solid 1px #516382; border-bottom: solid 1px #516382; border-left: solid 1px #516382; border-right: solid 1px #516382; padding: 5px'>
<img src='/site/images/bullet.gif' align='left'>$Post<br><br><i>--Stephen</i>
</td>
</tr>
</table>");

//Display links 
echo '<li><a href="/index.php?id=archives&entry='.$id.'">'.$date.' - '.$topic.'</a></li>';
}
    mysql_free_result($sql_result); 
    mysql_close($connection); 
} 
echo'</ul>';
} 
else 
{ 
    for($i=0; i<count($id); $i++) 
    { 
        if($entry==$id[$i]) 
        { 
            echo('$view');
            break; 
        } 
    } 
}
?>

Posted: Thu Apr 01, 2004 7:51 pm
by ol4pr0

Code: Select all

("Query failed. Please contact the site administrator, and b**ch at him.");
Maby the server is very mad @ ya ;-)

Posted: Thu Apr 01, 2004 7:51 pm
by kettle_drum
for($i=0; i<count($id); $i++)

should read:

for($i=0; $i<count($id); $i++)

(inclusion of the $ sign to say that i is a variable).

Posted: Thu Apr 01, 2004 7:52 pm
by markl999
echo('$view'); should be echo $view;

Posted: Thu Apr 01, 2004 8:06 pm
by seeker2921
Yes, My server generally is <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> at me for one reason or another..

I did both segestions and now I no longer get the timeout error, I get nothing, No errors and no view's..

I got to thinking when I was looking at my url.. does it matter if I call the page like this:

/index.php?id=archives&entry=25

??

Posted: Thu Apr 01, 2004 8:09 pm
by ol4pr0
You migth wanna check youre error logs

Posted: Thu Apr 01, 2004 8:22 pm
by seeker2921
I'm not sure if my webhost does the whole Error log thing for PHP I did find error logs but there wasn't anything in them about any of my scripts mainly just 404 error's..

Posted: Fri Apr 02, 2004 2:52 am
by twigletmac
Just in case you're missing any errors, put:

Code: Select all

ini_set('display_errors', 1);
error_reporting(E_ALL);
at the top of the page.

Mac

Posted: Fri Apr 02, 2004 3:19 am
by seeker2921
When I added that I got alot of error's I think what I will do is just delete all of it and start over again.. Perhaps I will have better luck trying in with two files instead of just one

Posted: Fri Apr 02, 2004 4:18 am
by twigletmac
And definitely make sure that you have display_errors turned on an error reporting set at it's highest level (E_ALL). Will make it much easier for you to work out what's going on.

Good luck :),
Mac

Posted: Fri Apr 02, 2004 3:23 pm
by seeker2921
Thanks!..

Posted: Fri Apr 02, 2004 5:00 pm
by seeker2921
Okay, So I re wrote the page and half of it works, The other does not heres the code that doesn't work:

Code: Select all

//Start entry view

//Vars
$entryid = $_POST["entryid"];

if($entryid=="$entryid"){
$sql = "SELECT DATE_FORMAT(date, '%M %e, %Y @ %h:%i %p') AS readable_date,topic,entry FROM $tablename WHERE $entryid";
$sql_result = mysql_query($sql, $conn)
	or die("Query failed!<br>".mysql_error()."<br>Please contact the site <a href=/?id=contact>administrator</a>, and bitch at him.");
}
while ($row = mysql_fetch_array($sql_result)) {


$date = $row["readable_date"];
$topic = $row["topic"];
$entry = $row["entry"]; 
$post = nl2br($entry);

echo "<table cellspacing='0' cellpadding='0' border='0'>
<tr>
<td width='150' align='left' valign='top' style='padding: 5px'>
<img src='/site/images/bullet.gif' align='left'><i><b>$topic</b></i><br>
<font size='1'><i>$date</i></font>
</td>
<td width='500' bgcolor=000000 align='left' valign='top' style='border-top: solid 1px #516382; border-bottom: solid 1px #516382; border-left: solid 1px #516382; border-right: solid 1px #516382; padding: 5px'>
<img src='/site/images/bullet.gif' align='left'>$post<br><br><i>--Stephen</i>
</td>
</tr>
</table>";
}
This is the error I get:
Notice: Undefined index: entryid in /home/stephen/public_html/site/blog/archives.php on line 32
Query failed!
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Please contact the site administrator, and bitch at him.

Posted: Fri Apr 02, 2004 5:02 pm
by markl999
Notice: Undefined index: entryid
Check the element on the form this is coming from is named entryid ok, (name="entryid") as it looks like it's named something else or it didn't get posted.

Posted: Fri Apr 02, 2004 5:04 pm
by Illusionist
if($entryid=="$entryid")

What is that supposed to be??

And your where clause is wrong, try soemthign like

WHERE id=$entryid

Posted: Fri Apr 02, 2004 5:04 pm
by seeker2921
I don't use a form, Its a simple url ?id=archives&entryid=25