Jump to content

taketimeout

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

taketimeout's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, that seems to work now, I have re-installed wamp and restored everything... One thing that might have been causing it is this: in the root index.php file, where I was including the index.php template file I had a constant called CONTENT_PATH that had the value of: "http://localhost/cms/views/cms" When I re-installed, I was getting the following warnings: Warning: require() [function.require]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\wamp\www\cms\index.php on line 7 Warning: require(http://localhost/cms/views/cms/index.php) [function.require]: failed to open stream: no suitable wrapper could be found in C:\wamp\www\cms\index.php on line 7 Fatal error: require() [function.require]: Failed opening required 'http://localhost/cms/views/cms/index.php' (include_path='.;C:\php5\pear') in C:\wamp\www\cms\index.php on line 7 Taking out the constant seems to have fixed it. I know... I didn't include THAT bit in my code. Thanks for all your help though 'BlueSkyIS' and 'kenrbnsn'. Chris
  2. Right. I'll try this on another server and see if I can get it working there. Thanks for clearing that up for me. I'll post back the results. Chris
  3. Well it should work... I have tried what you said, 'kenrbnsn', but that is pretty much what I am doing at the moment. Do you think it could be that I have the includes and functions files in a different directory? I will try moving them into the root with the index. <?php // IF YOU EXECUTE CODE FROM /views/cms/index.php here, it will have access to all functions in includes/functions.php. ?> I have tried that, and it works as it should, but accessing those functions from the "/views/cms/index.php" file doesn't. 'kenrbnsn', have you tried what you suggested on a test server? Chris
  4. I know that, but is there no way to use the functions that were included in the root index.php file? <?php //index.php //These functions are declared require ( "includes/functions.php" ); //Can this file not use the previously declared functions? require ( "views/cms/index.php" ); ?> That's what I want to do, if I can't do that then I will just include the functions in the "views/cms/index.php" file as well. Chris
  5. Thanks for the reply. Here is the code from "views/cms/index.php": <?php getMenuItems($dbh); ?> And the code that builds the menu: <?php function getMenuItems($dbh) { $sql = "SELECT * FROM posts WHERE menu_item = 1"; echo '<ul>'; foreach ( $dbh->query($sql) as $item ) { echo '<li>'; echo $item['slug']; echo '</li>'; } echo '</ul>'; } ?> When I run "getMenuItems();" from the root index.php the menu is printed out. Chris
  6. Hi. You could try: $home_url = 'http://' . $_SERVER['HTTP_HOST'] . '/admin.php'; header('Location: ' . $home_url); Just a starting point. Try echoing out each part to see where the back slash is coming from: echo $_SERVER['HTTP_HOST']; echo dirname($_SERVER['PHP_SELF']); Chris
  7. Hello. The title is a little confusing, but: What I am trying to do is build a simple CMS where all requests are routed through the root index.php file. This file will be where all constants are defined and importantly where the database connection is estabilished. There will be a folder where template files will reside and, based on the URI, a template file will be included into the root index.php file. Here's some code: <?php //Sets the database connection and defines some constants require ( "includes/config.php" ); //Where I will place the core functions of the CMS, one being the navigation builder require ( "includes/functions.php" ); //Home page template file require ( "views/cms/index.php" ); ?> So as you can see, I want to be able to call the navigation builder function, called "getMenuItems();", from the home page template. However, I get the following error: Fatal error: Call to undefined function getMenuItems() in C:\wamp\www\cms\views\cms\index.php on line 3 How can I access functions that have been defined in the "includes/functions.php" file, from the required template file "views/cms/index.php"? If you need anything else explaining then please ask. If this has already been posted, I apologise in advance! I have searched Google and the forums but nothing turned up. Chris
  8. taketimeout

    Hi

    Hi. I have some experience with PHP but there's some things I just can't get my head round. Hopefully you lot can help!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.