Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    2
    Thanked 1 Time in 1 Post

    Please solve my parse errors

    following is my php code and the error reads like this parse error in .../mainthead php at line 4 - unexpected T_STRING, expecting ',' or ';'

    <?php
    session_start();
    echo "<!--- Main Head Starts --->;
    \n<link href="assets/jodohStyles.css" rel="stylesheet" type="text/css" /> \n " ;
    \n<link rel="stylesheet" href="assets/style.css"/>
    \n";
    echo "<s";
    echo "tyle type="text/css">
    \n -->
    \n</style>;
    \n
    <div id="page">
    <span id="e1"></span>
    </div>
    \n <d";
    \n " ;
    $row
    $_SESSION
    $_SESSION
    ?>

  • #2
    Regular Coder
    Join Date
    Nov 2012
    Posts
    115
    Thanks
    7
    Thanked 12 Times in 12 Posts
    You're using the same double qoutes to set the link attributes as you are to open and close the echo string.

    PHP Code:
     echo "<!--- Main Head Starts --->;
     \n<link href="
    assets/jodohStyles.css" rel="stylesheet" type="text/css" /> \n " ;
    // should be
     
    echo "<!--- Main Head Starts --->";
     
    n<link href='assets/jodohStyles.css' rel='stylesheet' type='text/css' /> ";
    // or escape the double quotes using \" 
    Also, you close line 4 using " ; , but continue on line 5 with \n. That can't happen. I think the full lines you are looking for are:

    PHP Code:
    echo "<!--- Main Head Starts --->";
    echo 
    "\n<link href=\"assets/jodohStyles.css\" rel=\"stylesheet\" type=\"text/css\" /> \n " ;
    echo 
    "\n<link rel=\"stylesheet\" href=\"assets/style.css\"/> \n"
    In other words, if you end a line with a ; , you need to start the next line with an echo. Otherwise don't close the preceding line with ;, but use a dot instead.

    Hope that explains

    Regards,
    Martin

  • Users who have thanked Thyrosis for this post:

    ramsingh (11-27-2012)

  • #3
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,376
    Thanks
    263
    Thanked 32 Times in 31 Posts
    sorry but i hate when people do long strings of echo, its not only a pain to work with but its miserable to try to do normal code having to worry about quotes.


    why dont you just turn off php

    do your html

    then turn php back on

    and repeat the process. lol

    the problem is if you do echo nothing inside that echo can have double quotes unless its a special formated var using dots so you made my point exactly why i hate long strings of echo. You had double quotes inside of double quotes, you cant do that. if your echo has double quotes to start, you can use single quotes inside of that but the next double quote better be the close of that echo, as i said unless its a special formated php var statement.


    i left your session and row stuff alone, but you cant look at session that way you have to use print_r to do that, you can use the format you have only if you are looking at a particular key of session like

    to see all of session you can do

    PHP Code:
    print_r($_SESSION); 
    and to see a certain part of session you do this

    PHP Code:
    <?=$_SESSION['whatever'];?>
    you need to fix that down there before running this

    This is much cleaner
    PHP Code:

    <?php
    session_start
    ();
    ?>

    <!--- Main Head Starts --->

    <link href="assets/jodohStyles.css" rel="stylesheet" type="text/css" /> 
    <link rel="stylesheet" href="assets/style.css"/>

    <style type="text/css">

    /* put style stuff here */

    </style>

    <div id="page">
    <span id="e1"></span>
    </div>

    <br />
    <?=$row;?>
    <br />
    <?=$_SESSION;?>
    <br />
    <?=$_SESSION;?>
    Last edited by durangod; 11-27-2012 at 11:06 AM.

  • Users who have thanked durangod for this post:

    ramsingh (11-27-2012)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •