CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   Please solve my parse errors (http://www.codingforums.com/showthread.php?t=283054)

ramsingh 11-27-2012 09:24 AM

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

Thyrosis 11-27-2012 10:23 AM

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

durangod 11-27-2012 10:51 AM

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;?>



All times are GMT +1. The time now is 09:06 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.