SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jan 2012
    Location
    Bangalore
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Basic PHP setup problem: only the root PHP script works

    Hi, I am new to PHP and just setup PHP as per 'Build your own ....using PHP&MYSQL'. I have set up the wamp server and it shows all the information including PHP.ini and connects to MYSQL as well. I am placing my scripts in the www directory as shown by admin. The PHP instructions in the first script works but any PHP instructions in the html/included scripts are not doing anything. Can some one tell what may be the problem?

  2. #2
    SitePoint Member Code Beats's Avatar
    Join Date
    Dec 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you give a little more information about how you are including the scripts? How do the including and included scripts look like?

    The problem might be in the way you're providing the path to include() or maybe you're not placing PHP code tags correctly.

  3. #3
    SitePoint Member
    Join Date
    Jan 2012
    Location
    Bangalore
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A simple script like below does only the html part:
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <head>
            <title>Form Example</title>
            <meta http-equiv="content-type"
                    content="text/html; charset=utf-8"/>
        </head>
        <body>
            <p>  The name given are 
                <?php
                
    echo 'testing';
                
    ?>
            </p>
        </body>
    </html>
    where as the script below works:
    <?php
    $pageContents 
    = <<< EOPAGE
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    <html lang="en" xml:lang="en">
    <head>

            <title>Today date</title>
            <meta http-equiv="content-type"
                    content="text/html;"/>
        </head>
        <body>    
            <p>  The date is
    EOPAGE;
    $pageContents2 = <<< EOPAGE
                
                
            </p>
        </body>
    </html>
    EOPAGE;

    echo 
    $pageContents ;
    echo 
    date('l,F dS Y.') ;
    echo 
    $pageContents2;
    ?>
    Last edited by SpacePhoenix; Jan 5, 2012 at 01:13. Reason: placed php tags around the php code

  4. #4
    SitePoint Member Code Beats's Avatar
    Join Date
    Dec 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's weird that PHP code is not executing. Which enviroment are you using to execute your scripts? Did you install PHP and MySQL separately and built your own wamp or are you using WampServer?

    I've used EasyPHP and I haven't had any problems yet.

  5. #5
    SitePoint Member
    Join Date
    Jan 2012
    Location
    Bangalore
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have installed wamp server directly in windows xp environment. Some how the second level is not able to recognize PHP tags

  6. #6
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't have WampServer installed in my laptop but in my individual installation of PHP, Apache, MySQL the following does work quite well:
    Code html4strict:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    	<title>Form Example</title>
    	<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    </head>
    <body>
    <p> The name given are 
    <?php echo 'testing'; ?>
    </p>
    where as the script below works:
    <?php
    $pageContents = <<< EOPAGE
    <p> The date is
    EOPAGE;
    $pageContents2 = <<< EOPAGE
    </p>
    EOPAGE;
     
    echo $pageContents ;
    echo date('l,F dS Y.') ;
    echo $pageContents2;
    ?>
    </body>
    </html>

    Outputs:
    Code:
    The name given are testing
    where as the script below works:
    
    The date isThursday,January 05th 2012.
    BTW why you have html,body tags in the strings in heredoc ?
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Tags for this Thread

Bookmarks

Posting Permissions

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