Help - Search - Members - Calendar
Full Version: Passing Values
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
ap_
im trying to pass some variable values from the config.php to the index.php where
i have my class trying to do her thing.

index.php
CODE
<?php
require("config.php");
require("main.class");

$cn = new build;

print $cn->display();?>



config.php
CODE
<?php

$title = "test";
$keywords = "developing";
$margin = "30px";
$back = "media/black.bmp";

?>



main.class
CODE
<?php

ob_start();

class build{

var $title;
var $keywords;
var $margin;
var $backg;
var $font;
var $linkcolor;
var $none;


public function display(){
    print("<html>\n");
    print("<head>\n");
    print("<title>$this->title \n");
    print("$this->keywords</title>\n");
    print $this->cssdisplay();
    print("<head>\n");
    print("<body>\n");
    print $this->maincontent();
    print("</body>\n");
    print("</html>");

}


public function cssdisplay(){

    print("<style type=text/css>\n");
    print("    body{\n");
    print("    margin-top: $this->margin;\n");
    print("    background: url(\'$this->backg\');\n");
    print("    font: $this->font;\n");
    print("}\n");
    print("a:link{color: $this->linkcolor;}\n");
    print("a:active{color: $this->linkcolor;}\n");
    print("a:visited{color: $this->linkcolor;}\n");
    print("a:hover{color: $this->linkcolor; text-decoration: $this->none;}\n");
    print("</style>");


}

public function maincontent(){

/*if(!isset($_GET['id'])){
$id = "home";
}else{
$id = $_GET['id'];
}

switch($id){

}*/

}

}
ob_end_flush();

?>


some one could tellme what im doing wrong!

thanks by the way!
Jetteh22
True using

include 'config.php';
include 'main.class';

instead of require.

I use include with everything of that sort, always works for me?
ap_
tryied but nothing thanks by the way!
ill keep looking.

any help is welcome
pacho
Somthing in the PHP of the site doesn't works properly, y can't pass any information from one script to other, the following script works very well in my computer but not in my site in Zymic.

Script 1: "text.html"
<HTML>
<HEAD></HEAD>
<BODY>
<FORM METHOD=GET ACTION="text.php">
Who is your favourite author?
<INPUT NAME="Author" TYPE="TEXT">
<BR>
<BR>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>

Script 2: "text.php"

<HTML>
<HEAD></HEAD>
<BODY>
Your favorite author is:
<?php
echo $Author;
?>
</BODY>
</HTML>
House
Pacho - You will need to use $_GET['Author'].

Your new script would look like this:

CODE
<HTML>
<HEAD></HEAD>
<BODY>
Your favorite author is:
<?php
echo $_POST['Author'];
?>
</BODY>
</HTML>


Should work...
NDBoost
QUOTE(Creactive Online @ Apr 19 2008, 01:04 AM) *
True using

include 'config.php';
include 'main.class';

instead of require.

I use include with everything of that sort, always works for me?

Although include works, require or require_once is better especially when it comes to config files and required docs. You can do something like require_once(config.php) or die ("Blah blah blah"); Because if it does fail to include the file it will die and not finish processing the rest of the scripts.
Bogey
Does it still not work? If not, try setting a SESSION for it. And see if that works, although that may be unsecure, you can try that as a test.

Try including the config.php into main.php rather than into index.php
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.