Jump to content

brian914

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

brian914's Achievements

Member

Member (2/5)

0

Reputation

  1. I am building a php site and would like to keep all my page titles, copy, and certain image references inside a json file, so I can edit that info more easily and have it all in one place. I know how to load the json, but am wondering if there was a way to load it where it would only load once and then be stored in a variable that was available from any page. Maybe load it front he header include and store it in a session variable? I am pretty new to php, so hoping for some advice on how to do this best. Thanks a lot!
  2. Okay great. That is even better than what I thought it could be then! Thank you very very much! This is really nice of you to take all this time to answer my questions!
  3. Wow, amazing! Thank you so much Josh! I so very much appreciate the help! I have one last question in regards to your last comment: "This is common in for instance shared hosting environments, where multiple people share the same server." I guess I am a little bit worried about this, as in my experience, a lot of servers do share. So I was hoping to create a place where I could set a variable referring to "my root". I would like to do this, so if all of a sudden, when I move this to the actual server, or a different server, I could just set the "root" in one place, instead of having to go through all my code and look for the "$_SERVER['DOCUMENT_ROOT'].'/" and make the adjustment in many places. I was hoping there was something I could set in one place, like so: $my_root = $_SERVER['DOCUMENT_ROOT'] . '/somedirectory/'; Then I could use $my_root the rest of the time, instead of $_SERVER['DOCUMENT_ROOT']. But not sure if that is possible and not sure where that would reside? Maybe this is a pipe dream...
  4. Thank you so much for the help everyone! I really like the second solution for its simplicity and am wondering how I can apply that to include tags, which I can't seem to make work yet. While this seems to work: <img src="/img/home/home-04.jpg" alt="Home Image"> This doesn't work: <?php include '/inc/head.php'; ?> I have includes inside other includes files, so they still would all have to know where the "root" is. Thanks a lot!
  5. I am pretty new to php, so I apologize if this is a stupid question. I am building a web site and have include files that get used from the root and different sub directories within my site. For example I have a header include that gets used from files both on the root level and inside directories. Inside that header I need to for example call a style sheet. I am trying to do this like this: <link rel="stylesheet" href="<?php echo $_SERVER['DOCUMENT_ROOT']; ?>/css/style.css"> If I look at the source that this generates, here is what it looks like which is the correct path I think: <link rel="stylesheet" href="/Users/brian/Documents/Client Name/6_WebFiles/css/style.css"> But somehow the stylesheet does not seem to work. What am I doing wrong here? Thanks a lot for help!
  6. Could this be a permissions issue? And if so, what should it be and how do I set it?
  7. Thanks a lot for the suggestion! I don't really know what I am doing... But I have created a virtual host now and I like this for a number of reasons already. Is the following the correct way to refer to my style sheet? Somehow it is not quite working yet, and I wonder if it might be from the space in client name? Here is how I am calling the style sheet: <link rel="stylesheet" href="<?php echo $_SERVER['DOCUMENT_ROOT']; ?>/css/style.css"> If I look at the source, here is what it looks like which is the correct path: (I changed the client name, but it is two works just like below) <link rel="stylesheet" href="/Users/brian/Documents/Client Name/6_WebFiles/css/style.css"> Why wouldn't this pull in the style sheet?
  8. I am running MAMP and have a number of directories with different sites in my /Applications/MAMP/htdocs directory. The problem I am having is that inside one of those projects, I have a header file that gets included in pages that reside in different directories. So they need different paths for example for the style.css file. For example, from one file that path would be ../css/style.css but from another file inside another directory it would be ../../css/style.css. My question is if there is a way to set a "root" path for this projects, so I can use something like $root_dir . /css/style.css and it would always work, regardless of where in the site structure I am calling it from. Something similar to what wordpress does with TEMPLATEPATH.
  9. I am trying to figure out how to have an if statement in the middle of strings I am trying to concatenate. I have a from that has a address1 and address2, where address2 often does not exist. So I want to only add that line if there is actually content. I was trying something like the following, but that is giving me an error. I am pretty new to php, so I can't seem figure it out. Any help would be greatly appreciated. "<p><strong>Address 1: </strong><br>" . $address1 . "<br>" if ( isset($address2) ) { echo . $address2 . "<br>" } . $city . ", " . $state . " " . $zip . "</p>"
  10. Yes, thank you. That I think is all I need!!!
  11. I am about to build a site for a liqueur brand and have to create a simple screen that asks if the user is of the right age. This does not have to be linked to a credit card, just a simple yes or no screen. I am thinking this would probably be done via a cookie, but I am not sure. Somehow it would have to work where it gets checked each time anyone goes to the site, regardless of the entry point. So for example it would get checked on mydomain.com, but also on mydomain.com/about, or mydomain.com/somethingelse. The yes or no screen would of course only show the first time the user came to site. Via what technology would I do this? Cookie? Can cookies have an expiration date? I would love some comments or direction on how this is done best. Thanks a lot!
×
×
  • 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.