PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
seeker2921
Forum Contributor
Posts: 120 Joined: Sat Mar 22, 2003 7:10 pm
Location: Wiesbaden Germany
Contact:
Post
by seeker2921 » Thu Apr 01, 2004 7:48 pm
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;
}
}
}
?>
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Thu Apr 01, 2004 7:51 pm
Code: Select all
("Query failed. Please contact the site administrator, and b**ch at him.");
Maby the server is very mad @ ya
kettle_drum
DevNet Resident
Posts: 1150 Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England
Post
by kettle_drum » Thu Apr 01, 2004 7:51 pm
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).
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Thu Apr 01, 2004 7:52 pm
echo('$view'); should be echo $view;
seeker2921
Forum Contributor
Posts: 120 Joined: Sat Mar 22, 2003 7:10 pm
Location: Wiesbaden Germany
Contact:
Post
by seeker2921 » Thu Apr 01, 2004 8:06 pm
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
??
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Thu Apr 01, 2004 8:09 pm
You migth wanna check youre error logs
seeker2921
Forum Contributor
Posts: 120 Joined: Sat Mar 22, 2003 7:10 pm
Location: Wiesbaden Germany
Contact:
Post
by seeker2921 » Thu Apr 01, 2004 8:22 pm
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..
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Fri Apr 02, 2004 2:52 am
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
seeker2921
Forum Contributor
Posts: 120 Joined: Sat Mar 22, 2003 7:10 pm
Location: Wiesbaden Germany
Contact:
Post
by seeker2921 » Fri Apr 02, 2004 3:19 am
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
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Fri Apr 02, 2004 4:18 am
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
seeker2921
Forum Contributor
Posts: 120 Joined: Sat Mar 22, 2003 7:10 pm
Location: Wiesbaden Germany
Contact:
Post
by seeker2921 » Fri Apr 02, 2004 3:23 pm
Thanks!..
seeker2921
Forum Contributor
Posts: 120 Joined: Sat Mar 22, 2003 7:10 pm
Location: Wiesbaden Germany
Contact:
Post
by seeker2921 » Fri Apr 02, 2004 5:00 pm
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.
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Fri Apr 02, 2004 5:02 pm
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.
Illusionist
Forum Regular
Posts: 903 Joined: Mon Jan 12, 2004 9:32 pm
Post
by Illusionist » Fri Apr 02, 2004 5:04 pm
if($entryid=="$entryid")
What is that supposed to be??
And your where clause is wrong, try soemthign like
WHERE id=$entryid
Last edited by
Illusionist on Fri Apr 02, 2004 5:04 pm, edited 1 time in total.
seeker2921
Forum Contributor
Posts: 120 Joined: Sat Mar 22, 2003 7:10 pm
Location: Wiesbaden Germany
Contact:
Post
by seeker2921 » Fri Apr 02, 2004 5:04 pm
I don't use a form, Its a simple url ?id=archives&entryid=25