Unexpected $ on line 75

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

Post Reply
danharibo
Forum Commoner
Posts: 76
Joined: Thu Aug 17, 2006 8:56 am

Unexpected $ on line 75

Post 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
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

Try removing that extra } above the else statement.
danharibo
Forum Commoner
Posts: 76
Joined: Thu Aug 17, 2006 8:56 am

Post by danharibo »

Parse error: parse error, unexpected $ in /home/razor/public_html/ror_upload/file.php on line 75 :(
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Post all relevent code, especially lines 70 to 80.
danharibo
Forum Commoner
Posts: 76
Joined: Thu Aug 17, 2006 8:56 am

Post 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 <?
}
?>
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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 <?
}
?>
danharibo
Forum Commoner
Posts: 76
Joined: Thu Aug 17, 2006 8:56 am

Post 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 ;)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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?
Post Reply