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!
You should probably look through your line by line. There are quite a few problems with it. I have highlighted a few in UPPER CASE comments in your code, but take note that the code you posted in missing two closing brackets (the first if check and the the first while loop) so right off the pop your code is going to have errors. Also, you are using short PHP tags throughout your script which could also be causing problems. You should ditch those.
<?php
if(isset($_GET['id']))
{
$id = $_GET['id'];
$sql = "SELECT * FROM ez_downloads WHERE id = '$id' ";
$result = mysql_query($sql) or print ("Can't select entries For Item .<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
$title = stripslashes($row['name']);
$user = stripslashes($row['submit_by']);
$entry = stripslashes($row['description']);
$id = $row['id'];
$filename = $row['filename'];
$img = $row['screen'];
// AT THIS POINT WE ARE STILL IN A WHILE LOOP AND IN THE ISSET CHECK
// THERE IS AN ENORMOUS USE OF SHORT TAGS IN THE NEXT SEGMENT OF CODE
?>
<a NAME="<? echo $id; ?>"></a> <p><strong><?php echo $title; ?></strong><br />
<strong>submited by: <? echo $user ?></strong><br />
<strong>ID:<? echo $id; ?></strong><br />
<?php echo $entry; ?><br />
<?
// SHORT OPENING TAGS CAN CAUSE COMPATIBILITY ISSUES
//Empty image test
if($img == '')
{
print('<img src="images/No_img.png" />');
}
else
{
echo "Image: <br />";
// NOTE WE ARE INSIDE AN ELSE INSIDE A WHILE INSIDE AN IF
?><img src="<? echo $img; ?>" /> <? } ?><br><br />
<? print("<a href=".$filename.">DOWNLOAD</a>"); ?>
</p>
<?
} // CLOSES THE ELSE, WE ARE STILL IN WHILE AND IF
?>
<hr>
<?
//Comments
$sql = "SELECT * FROM ez_commenst WHERE truckid = '$id' ";
$result = mysql_query($sql) or print ("Can't select entries For Comments Item .<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
$title = stripslashes($row['title']);
$entry = stripslashes($row['entry']);
$email = stripslashes($row['email']);
$id = $row['id'];
?>
<a NAME="<? echo $id; ?>"></a> <p><strong><?php echo $title; ?></strong><br />
<strong>E-mail/WWW: <a href="<? echo $email; ?>"><? echo $email; ?></a></strong><br />
<?php echo $entry; ?><br />
<?php // I ADDED THIS ONE BECAUSE IT WAS MISSING
} // CLOSES INNER WHILE, WE ARE STILL INSIDE A WHILE AND IF
else // YOU CANNOT ELSE A WHILE LOOP
{
?> Please enter a truck ID <?
}
?>
Not necessarily on topic, but it should be written for portability. What happens if you switch hosts, or better yet, PHP decides that in say, PHP 6, to not support short tags at all. Then what?
Back on topic, have you handled the closing brackets yet?