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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Posts
    140
    Thanks
    8
    Thanked 0 Times in 0 Posts

    CSS in PHP code?

    A big thanks to the people who contribute to this thread

    I am trying to output the PHP code on the line with the comment, what am I doing wrong,

    Parse Error

    Parse error: syntax error, unexpected 'value' (T_STRING), expecting ',' or ';' in C:\Xampp\htdocs\1\index.php on line 28


    Code:
    <html>
    <head>
    
    <link href="style.css" rel="stylesheet" type="text/css">
    
    
    </head>
    <style>
    p.value
    {
    text-align:center;
    background-color: gray;
    }
    body {
    background-color:black;
    color: white;
    }
    </style>
    <body>
    
    <?php
    
    if(isset($_POST['submit'])&&!empty($_POST['name'])) 
    { 
        $name = $_POST['name'];
        echo "You submitted the form and entered this name :
    	?>
    //problem line <b><i> <p class="value"><?php echo "$name ; ?> </i></b></p>";
    <?php
    }    
    else{
    ?>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
       <input type="text" name="name"><br>
       <input type="submit" name="submit"><br>
    </form>
    <?php
    }
    ?>
    
    </body>
    </head>
    Last edited by VIPStephan; 01-02-2014 at 09:41 PM. Reason: corrected code BB tags

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,472
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Problem Line:

    echo "You submitted the form and entered this name :

    You don't terminate either the string or the statement.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    amcf1992 (01-02-2014)

  • #3
    New Coder
    Join Date
    Oct 2013
    Posts
    16
    Thanks
    2
    Thanked 1 Time in 1 Post

    CSS in PHP code?

    PHP Code:
    echo "You submitted the form and entered this name :
        ?>
    //problem line <b><i> <p class="value"><?php echo "$name ; ?> </i></b></p>";
    A few areas, first off you can't close off the code after "entered this name" and then again after $name(yu didn't start it back up at<b> and udidn't have to. If you want to echo everything out wrap it all in single quotes ' ' and use the php concantenation operator '.'
    like so
    PHP Code:
    <?php

    if(isset($_POST['submit'])&&!empty($_POST['name'])) 

        
    $name $_POST['name'];
        echo 
    'You submitted the form and entered this name : 
      <b><i><p class="value">'
    .$name.'</i></b></p>';
    [/PHP]
    I tested it and it works.

  • #4
    New to the CF scene
    Join Date
    Jan 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i have just finished all of my php but when i visit my website its a wite page saying "INDEX OF/"
    "cg2" whats going on email me its much better Badmurd@googlemail.com

  • #5
    Regular Coder
    Join Date
    Jul 2011
    Posts
    140
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rhodoscoder View Post
    PHP Code:
    echo "You submitted the form and entered this name :
        ?>
    //problem line <b><i> <p class="value"><?php echo "$name ; ?> </i></b></p>";
    A few areas, first off you can't close off the code after "entered this name" and then again after $name(yu didn't start it back up at<b> and udidn't have to. If you want to echo everything out wrap it all in single quotes ' ' and use the php concantenation operator '.'
    like so
    PHP Code:
    <?php

    if(isset($_POST['submit'])&&!empty($_POST['name'])) 

        
    $name $_POST['name'];
        echo 
    'You submitted the form and entered this name : 
      <b><i><p class="value">'
    .$name.'</i></b></p>';
    [/PHP]
    I tested it and it works.

    Thanks works perfectly!


  •  

    Posting Permissions

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