Unexpected $ Where There Aren't Any

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Unexpected $ Where There Aren't Any

Amezis
I am getting this message when testing a script I made:
QUOTE
Parse error: parse error, unexpected $ in /home/globa38/public_html/forum/mods/phpbb_fetch_all/news/forumnews.php on line 159


On line 159, which is the last line in that file, I can only see this:
CODE
?>


What's the problem, and how can I fix it? unsure.gif

Reply

sxyloverboy
can you post codelines 150 - 170? that would give some more insight on this problem.

Reply

Amezis
CODE
<?
for ($i = 0; $i < count($news); $i++) {
{
$max_length = 27;
$title = ($news[$i]['topic_title']);
$title_length = strlen($title);
if ($title_length > $max_length)
{
$title = substr_replace($title, '...', $max_length);
}
?>
    <tr>
      <td class="newshover">
      <?php echo append_sid('http://forum.global-rs.com/viewtopic.php?t=' . $news[$i]['topic_id']); ?>">
      <?php echo date('d-M-Y',$news[$i]['post_time']); ?> - <?php echo($title); ?></a></td>
    <tr>
<?php
}
?>

 

 

 


Reply

sxyloverboy
hmm idunno
maybe you can try this:

change
CODE
<?php echo date('d-M-Y',$news[$i]['post_time']); ?> - <?php echo($title); ?></a></td>


to:

CODE
<?php echo date('d-M-Y',$news[$i]['post_time']); ?> - <?php
echo $title;
?></a></td>


Reply

rvalkass
As far as I can see you have some extra braces. You have one extra { at the beginning that is never closed. Also, try not to break out of PHP into HTML in the middle of a for loop, as it can sometimes cause problems. Just put each line as an echo.

Reply

Amezis
Okay, I have changed the code as you said, sxyloverboy, and I have put the HTML code in echo(). But still, the problem is happening.

Reply

sxyloverboy
hm looking at this thread i see that the problem was a curly brace "{" that wasnt closed. look though all of your code to see if you find something that you havent closed. if that dosent help i dunno.

Reply

beeseven
When it says that there's an unexpected $ on the last line of the file, that always means that you didn't close all of your curly braces ( { ).

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : unexpected, arent

  1. Unexpected T_string In User.php [resolved]
    (5)
  2. Unexpected T_variable...
    Help! (3)
    I did construct the database connection file which is called "config.php". But, I got some mistake
    that has to be solved to continue with working. This is the code itself: //Set the database
    values $confg ="alex1985_admin" //Your database username $confg ="" //Your database
    user's password $confg ="localhost" //Your host $confg ="books" //Your database name
    //Create the function to log into the DB function db_login() { global $confg; $link =
    @mysql_connect($confg , $confg , $confg ) or die("Error connecting: " . mysql....
  3. Php Escaped Control Characters And Windows
    they aren't working for me. (3)
    In php coding, when you escape certain characters, they have an impact on the output of an
    echo'd or printed string. ie "\r\n\t" should give you a new line and a tab before
    outputting the content for a line of printing. They vary by OS, I know, but I have tried all the
    variations I can think of and can't seem to control output using them. Believe me, I have tried
    multiple variations and nothing works for me. I have checked the php.ini file for settings but I
    can't find where you can modify them. So the question is : Where do i look to conf....
  4. Parse: Error Unexpected T_lnumber
    php parse error when running script (4)
    Hi. I've just created a php script. The main object of the script is to delete some old files
    and replace it with a new file with some new content, effectively moving the contents from one file
    to another. These are the first 50 lines of the file: /* Calculate For The "A" Group - The
    Latest Games ID */ $a_B = 002; while(file_exists("a_" . $a_B . ".dat")) {
    $a_B++; } $new_page_contents = " " . $_POST . " " . $_POST . "
    include \"/home/cmatcme/public_html/footer.php\"; ?> "; $a_stream = fopen(&....
  5. Parse Error
    unexpected $ (1)
    i have this code CODE <?php if($_POST['user']=="" or
    $_POST['pass']=="" or $_POST['host']==""
    or $_POST['root']=="" or
    !isset($_POST['run'])){  print('<form method=post
    name=form>');  print('FTP username <input type=\'text\'
    name=user value=""><br>');  print('FTP password <input
    type=\'password\....
  6. Unexpected "$" Sign On Last Line Of File
    even if i change the line nos it's there (3)
    I am trying to create a file which send mail after a user has filled in the appropiate fields in a
    form. It checks to see whether the required fields are full, writes some mail headers and sends it.
    When I check to see if the code works, I get this error: QUOTE(affliates.cmat) Parse error:
    parse error, unexpected $ in /home/cmatcme/public_html/affliates.cmat on line 203 The
    funny thing is that regardelss of how long I make the file, the file always appear on the final
    line, whether I leave it blank or just put ?> . I understand that these errors ca....
  7. Unexpected $
    what does it mean (9)
    You see I have a most intresting problem, basicaly I get the following error: QUOTE Parse error:
    parse error, unexpected $ in /path/result.php on line 99 Now normaly when I have problems
    I go to line 99 and add a ; or a " or something the problem is in my file line 99 is , CODE
     <tr bgcolor="#FFFFFF">    <td width="25" height="5"
    background="images/q3.png"> </td>    <td height="25"
    align="right" valign="top" background="images/bot.png"><span cla....

    1. Looking for unexpected, arent

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for unexpected, arent

*MORE FROM TRAP17.COM*
advertisement



Unexpected $ Where There Aren't Any



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE