Page 1 of 1
Unexpected $ on line 75
Posted: Fri Oct 06, 2006 12:38 pm
by danharibo
Code: Select all
$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 />
}
}
else
{
?> Please enter a truck ID <?
}
?> "Line 75"
What is causing this nonsense
Posted: Fri Oct 06, 2006 12:44 pm
by impulse()
Try removing that extra } above the else statement.
Posted: Fri Oct 06, 2006 12:47 pm
by danharibo
Parse error: parse error, unexpected $ in /home/razor/public_html/ror_upload/file.php on line 75

Posted: Fri Oct 06, 2006 1:26 pm
by RobertGonzalez
Post all relevent code, especially lines 70 to 80.
Posted: Fri Oct 06, 2006 1:31 pm
by danharibo
Code: Select all
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'];
?>
<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 />
<?
//Empty image test
if($img == '')
{
print('<img src="images/No_img.png" />');
}
else
{
echo "Image: <br />";
?><img src="<? echo $img; ?>" /> <? } ?><br><br />
<? print("<a href=".$filename.">DOWNLOAD</a>"); ?>
</p>
<?
}
?>
<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 />
}
else
{
?> Please enter a truck ID <?
}
?>
Posted: Fri Oct 06, 2006 1:40 pm
by RobertGonzalez
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.
Code: Select all
<?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 <?
}
?>
Posted: Fri Oct 06, 2006 2:19 pm
by danharibo
Everah wrote: Also, you are using short PHP tags throughout your script which could also be causing problems. You should ditch those.
My code is not wirten For Distrubution

Posted: Fri Oct 06, 2006 2:35 pm
by RobertGonzalez
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?