Nuggit Posted November 26, 2007 Share Posted November 26, 2007 This is the first part of myblog.php, which is the page you see in the browser. <?php require("/home/www/htdocs/master.php"); //functions are in here $u = "test"; //username $htitle = "Test blog!"; //for <title> //includes dbcon(); //connect to database blog($u); // START PAGE echo $welcomemessage; Functions are in master.php. It calls function dbcon, which logs me into MySQL and selects the database. It calls function blog: function blog($u) { //not using $u for anything yet. require($path."blog/vars.php"); require($path."blog/head.php"); } Vars defines stuff needed for the blog, Head is the header, with <html>, <head>, etc. $welcomemessage is defined in vars.php, but it doesn't show anything when I echo it in myblog.php. I went into vars.php and made it echo in there, and it worked, so it is defined correctly and the file is included, but for some reason the variable goes blank by the time I get back to myblog.php. It's the same with all the arrays I defined in there too. What's going on? I am using: PHP 5.2.3-1ubuntu6 Ubuntu 7.10 Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 26, 2007 Share Posted November 26, 2007 Check out scope, its a common issue with this, you can't scope UP basically Quote Link to comment Share on other sites More sharing options...
revraz Posted November 26, 2007 Share Posted November 26, 2007 Search for Pass by Reference. Quote Link to comment Share on other sites More sharing options...
Nuggit Posted November 26, 2007 Author Share Posted November 26, 2007 Check out scope, its a common issue with this, you can't scope UP basically Oh wow. I tried it without using that handy blog() function and directly requiring them instead, and now it seems to work. I just need to avoid doing that with functions, then? edit: or, I could still use the function if I make it &blog()? I'm reading about references now. Thanks guys. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.