What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » simple php help

simple php help
Author: Message:
Supersonicdarky
Veteran Member
*****

Avatar

Posts: 2317
Reputation: 48
– / – / Flag
Joined: Feb 2005
Status: Away
O.P. simple php help
i hardly know any php, so i probably made a silly mistake and everyone's gonna laugh at me ;<

anyways, to make things easier, i decided to split a page up into different sections (in a different file) and included it on every page, but it only shows 3 random characters when it loads ;<

static_content.php

code:
<?php
$header = '<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="css.css" type="text/css" />

<title>123</title>
</head>'

$body ='<body>

<div id="container">
    <div id="header"></div>
    <div id="content">'
   
$sidebar ='<div id="sidebar">
            <ul>
            <li><a href="novosti.php"><b>123</b></a></li>
            <br />
            <li><b>123</b></li>
                <ul>
                <li><a href="detskii_sad.php"><i>• 123</i></a></li>
                <li><a href="sybot_shkola.php"><i>• 123</i></a></li>
                <li><a href="podgotov_shkola.php"><i>• 123</i></a></li>
                <li><a href="klass_taekwon_do.php"><i>• 123</i></a></li>
                <li><a href="letnii_lager.php"><i>• 123</i></a></li>
                <li><a href="program_do_i_posle.php"><i>• 123</i></a></li>
                <li><a href="music_shkola.php"><i>• 123</i></a></li>
                <li><a href="shkola_horeographii.php"><i>• 123</i></a></li>
                <li><a href="russkii_kak_deti.php"><i>• 123</i></a></li>
                <li><a href="francyzskii_deti.php"><i>• 123</i></a></li>
                </ul>
            <li><b>123</b></li>
                <ul>
                <li><a href="ansambl_kalinka.php"><i>• 123</i></a></li>
                <li><a href="klass_aerobiki.php"><i>• 123</i></a></li>
                <li><a href="workshop.php"><i>• Workshop</i></a></li>
                <li><a href="russkii_kak_vzros.php"><i>• 123</i></a></li>
                <li><a href="francyzskii_vzros.php"><i>• 123</i></a></li>
                <li><a href="angliskii.php"><i>• 123</i></a></li>
                </ul>
            <li><a href="http://www.pokrov.ca/School/schoolalbum.php" target="_blank"><b>123</b></a></li>
            <li><a href="adres.php"><b>123</b></a></li>
            <li><a href="index.php"><b>123</b></a></li>
            </ul>
        </div>'
       
$footer = '</div>
   
    <div id="footer">
        <p>&copy; 2007</p>
    </div>
   
</div>
</body>
</html>'
?>



and the page

code:
<?php
    include'static_content.php';
    print $header;
    print $body;
?>


    <div id="main">
        <p>Francyzskii yazik</p>
    </div>
   
<?php
    print $footer;
?>


whats wrong? i tried with echo and return, same thing happens ;<
04-01-2007 02:25 AM
Profile E-Mail PM Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
RE: simple php help
the include should be:
code:
include('static_content.php');
or
code:
require('static_content.php');


also you should note:
whenever you echo something e.g
code:
echo "I am cool";

It must always end with ; (after the ' or ") otherwise it doesnt know what to do.

This post was edited on 04-01-2007 at 02:38 AM by Nathan.
04-01-2007 02:31 AM
Profile E-Mail PM Web Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: simple php help
maybe try this:
code:
<?php
$header = '<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="css.css" type="text/css" />

<title>123</title>
</head>';

$body ='<body>

<div id="container">
<div id="header"></div>
<div id="content">';

$sidebar ='<div id="sidebar">
<ul>
<li><a href="novosti.php"><b>123</b></a></li>
<br />
<li><b>123</b></li>
<ul>
<li><a href="detskii_sad.php"><i>• 123</i></a></li>
<li><a href="sybot_shkola.php"><i>• 123</i></a></li>
<li><a href="podgotov_shkola.php"><i>• 123</i></a></li>
<li><a href="klass_taekwon_do.php"><i>• 123</i></a></li>
<li><a href="letnii_lager.php"><i>• 123</i></a></li>
<li><a href="program_do_i_posle.php"><i>• 123</i></a></li>
<li><a href="music_shkola.php"><i>• 123</i></a></li>
<li><a href="shkola_horeographii.php"><i>• 123</i></a></li>
<li><a href="russkii_kak_deti.php"><i>• 123</i></a></li>
<li><a href="francyzskii_deti.php"><i>• 123</i></a></li>
</ul>
<li><b>123</b></li>
<ul>
<li><a href="ansambl_kalinka.php"><i>• 123</i></a></li>
<li><a href="klass_aerobiki.php"><i>• 123</i></a></li>
<li><a href="workshop.php"><i>• Workshop</i></a></li>
<li><a href="russkii_kak_vzros.php"><i>• 123</i></a></li>
<li><a href="francyzskii_vzros.php"><i>• 123</i></a></li>
<li><a href="angliskii.php"><i>• 123</i></a></li>
</ul>
<li><a href="http://www.pokrov.ca/School/schoolalbum.php" target="_blank"><b>123</b></a></li>
<li><a href="adres.php"><b>123</b></a></li>
<li><a href="index.php"><b>123</b></a></li>
</ul>
</div>';

$footer = '</div>

<div id="footer">
<p>&copy; 2007</p>
</div>

</div>
</body>
</html>';
?>

code:
<?php
include('static_content.php');
echo $header;
echo $body;
echo $sidebar;
?>


<div id="main">
<p>Francyzskii yazik</p>
</div>

<?php
echo $footer;
?>


added some ; into the first one after the ended variables (they should be making errors if they werent there...)... also changed to echo

This post was edited on 04-01-2007 at 02:44 AM by NanaFreak.
04-01-2007 02:35 AM
Profile PM Find Quote Report
Supersonicdarky
Veteran Member
*****

Avatar

Posts: 2317
Reputation: 48
– / – / Flag
Joined: Feb 2005
Status: Away
O.P. RE: simple php help
but according to this what i was doing is correct...

and neither work...

@nathan: " and " aren't used for $vars

---

yay, works! thnx nana dude =]

This post was edited on 04-01-2007 at 02:43 AM by Supersonicdarky.
04-01-2007 02:38 AM
Profile E-Mail PM Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
RE: simple php help
see my updated post...
04-01-2007 02:40 AM
Profile E-Mail PM Web Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: simple php help
quote:
Originally posted by Supersonicdarky
@nathan: " and " aren't used for $vars
if you use " (double quote not ' x2) then you are able to use $vars but not if you use ' ;)

quote:
Originally posted by Supersonicdarky
yay, works! thnx nana dude =]
np :)
04-01-2007 02:46 AM
Profile PM Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
RE: simple php help
Originally posted by Supersonicdarky
yay, works! thnx nana dude =]

*cough* I explained what to do, nanafreak just gave you the code :P
04-01-2007 02:48 AM
Profile E-Mail PM Web Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: simple php help
quote:
Originally posted by Nathan
Originally posted by Supersonicdarky
yay, works! thnx nana dude =]

*cough* I explained what to do, nanafreak just gave you the code :P
*cough*
quote:
Originally posted by NanaFreak
added some ; into the first one after the ended variables (they should be making errors if they werent there...)... also changed to echo
*cough*
04-01-2007 02:50 AM
Profile PM Find Quote Report
Supersonicdarky
Veteran Member
*****

Avatar

Posts: 2317
Reputation: 48
– / – / Flag
Joined: Feb 2005
Status: Away
O.P. RE: simple php help
something is being very retarted

look in ie, then click any link.

where does the random &#65279;< or w.e come from?

source of:

inde.php
code:
<?php
include('static_content.php');
echo $header;
echo $body;
echo $sidebar;
?>


<div id="main">
<h1>Blah</h1>
</div>

<?php
echo $footer;
?>


detskii_sad.php
code:
<?php
include('static_content.php');
echo $header;
echo $body;
echo $sidebar;
?>


<div id="main">
    <p>Detskii sad</p>
</div>

<?php
echo $footer;
?>


static_content.php
code:
<?php
$header = '<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="css.css" type="text/css" />

<title>123</title>
</head>';

$body ='<body>

<div id="container">
<div id="header"></div>
<div id="content">';

$sidebar ='<div id="sidebar">
        <ul>
        <li><a href="o_centre.php"><b>123</b></a></li>
        <br />
        <li><b>123</b></li>
            <ul>
            <li><a href="detskii_sad.php"><i>• 123</i></a></li>
            <li><a href="sybot_shkola.php"><i>• 123</i></a></li>
            <li><a href="podgotov_shkola.php"><i>• 123</i></a></li>
            <li><a href="klass_taekwon_do.php"><i>• 123</i></a></li>
            <li><a href="letnii_lager.php"><i>• 123</i></a></li>
            <li><a href="program_do_i_posle.php"><i>• 123</i></a></li>
            <li><a href="music_shkola.php"><i>• 213</i></a></li>
            <li><a href="shkola_horeographii.php"><i>• 123</i></a></li>
            <li><a href="russkii_kak_deti.php"><i>• 123</i></a></li>
            <li><a href="francyzskii_deti.php"><i>• 123&#1082;</i></a></li>
            </ul>
        <li><b>123</b></li>
            <ul>
            <li><a href="ansambl_kalinka.php"><i>• 123</i></a></li>
            <li><a href="klass_aerobiki.php"><i>• 123</i></a></li>
            <li><a href="workshop.php"><i>• 123</i></a></li>
            <li><a href="russkii_kak_vzros.php"><i>• 123</i></a></li>
            <li><a href="francyzskii_vzros.php"><i>• 123</i></a></li>
            <li><a href="angliskii.php"><i>• 123</i></a></li>
            </ul>
        <li><a href="schoolalbum.php" target="_blank"><b>123</b></a></li>
        <li><a href="adres.php"><b>123</b></a></li>
        <li><a href="index.php"><b>123</b></a></li>
        </ul>
    </div>';

$footer = '</div>
</div>

<div id="footer">
<p>&copy; 2007</p>
</div>

</body>
</html>';
?>


look here (first error) or look at source in ie to see what i'm talking about

i'm guessing that will solve the retartedness when you click a link

edit: everything saved as utf-8

This post was edited on 04-02-2007 at 11:56 PM by Supersonicdarky.
04-02-2007 11:55 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On