Jump to content

dalawh

Members
  • Posts

    127
  • Joined

  • Last visited

Everything posted by dalawh

  1. I solved it... getdate() is a function that was already built in. It seems it is case insensitive. http://www.php.net/manual/en/function.getdate.php
  2. Does not seem to work. When I just echo the date, it works fine, but when I turn it into a function and call it, I get an error.
  3. Yea, I could not figure it out. It is a pain. The reason that I am not combining them into one is because I am using the getDate() multiple times throughout multiple files.
  4. I been trying ti figure this out for a few hours now and I can't seem to figure it out. Hopefully, someone will be able to solve my dilemma. The error I get is "Fatal error: Cannot redeclare getDate() in C:\xampp\htdocs\dalawh\date.php on line 4" test.php <?phprequire 'date.php';$data=$last.' | '.$first.' | '.getDate().' | '.$_SERVER['SCRIPT_FILENAME'];echo $data;?> date.php <?phpfunction getDate(){echo date("l, M j, Y g:i:s A T");}?> When I comment out "require 'date.php'", everything works fine, but of course getDate() returns nothing. So I figured it had to do with that line. I thought it may have been the echo in date.php, so I tried return, but I still got the same error.
  5. I get what jsg and sc are trying to say. I personally like sc methods because it is much simplier, but jsg does make sense. Thanks for your input.
  6. Sorry about that. I just typed it quickly. Oh okay. Just wanted to make sure. It doesn't make a difference even if the file gets quite big?
  7. When I am coding in a php file (.php extension), is it better to reduce the php area to as small as possible (like in the first case) or does it not matter (like the second case)? <html><body><?php//Some php code?></body></html> OR <?php<html><body>//Some php code</body></html>?>
  8. dalawh

    Redirecting

    Okay. Thanks for the help.
  9. dalawh

    Redirecting

    I am using an if and else statement. it will display the index.php if the cookies are set and it will display the other.php if the cookies are not set. I have been using the header function to redirect. instead of using require/include to display the page. Is there a better way to redirect the pages or is the header the best way?
  10. Yea, I know. I am using the functions multiple times throughout the site.
  11. Oh okay. I was thinking about just leaving the main functions in one file and just call them, but looks like that failed.
  12. I know that require give an error and include gives warnings when something goes wrong. I assume require is used for something that you want on the page like a navigation bar or something that appears on multiple pages that doesn't change. I am trying to use include to use a function in another php file, but it seems it only works if I use all the functions in that php page. Is there any way to only use some of the functions and not all? Also, the once means it only shows up once, so any repeats will not show up. Does this apply to each page or the whole site altogether?
  13. dalawh

    Session

    I understand this completely. I didn't know the term for it, so I called it file variables, but it seems it is called settings. I know it is not called index. Things inside [] are the index. That is the general programming term. I did not know what they were called, so I just called them file variables. Thanks for this. I will try it out. Now that makes perfect sense. Thanks for idiot proofing it
  14. dalawh

    Session

    I thought it was pretty obvious that I had access to the server. I been trying to say that in order for me to use session correctly, I must first understand it.
  15. dalawh

    Session

    I feel like I am being somewhat repetitive. I am sorry for taking up your time, but I like to get things straight and fully understood, which saves me time in the long run. I used to bs my way through before without understanding things and it only made things more complicated in the end. Please correct me if I am wrong. Each $_COOKIE has its own index ($_COOKIE['indexName']) aka the cookiesand each index/cookie has its own file variables.I am trying to picture the same for the $_SESSION on the server side. I already understand the client side (cookie). Each $_SESSION has its own index ($_SESSION['indexName']) and each index has its own file variables. I am trying to figure out what file variables are listed under the indexes of $_SESSION. I hope this makes more sense. The index are defined in the php.ini. Each user has its own session cookie ($_COOKIE), which has a SID that matches with a $_SESSION on the server. Where is that SID stored in the $_SESSION? Is it a file variable stored under all the indexes of the $_SESSION or does it have its own index? I can view my cookies using chrome, but how can I view my sessions?
  16. dalawh

    Session

    The reason I asked about the format is because I wanted to know what type of data it stores that way I know what I can use it for. That makes sense, but the bold made it a little hard to read. Quite distracting, but I see your point of using it. All that is left is to understand the data on the server. Can you explain that? Like what it looks like and what can be stored, etc.
  17. dalawh

    Session

    I know how a session cookie looks like and what variables it contains, but I am still unsure how a session looks like on a server.
  18. dalawh

    Session

    Even if you can encode everything in the content, those seven variables do mean something. I was wondering if sessions had the same and if they did, can you link me to them. If a session closes when the page closes, the 15 minutes is unrelated to it? So even after the session closes, the cookie of the SID doesn't get deleted? All of the sessions gets saved on the server even after it closes? When does it permanently get deleted?
  19. dalawh

    Session

    That somewhat sounds like what I mean. Just like how cookies only contain these 7 variables: http://www.php.net/manual/en/function.setcookie.php, I wanted to know if sessions contained certain variables. If it did can you link me because I can't seem to find it. Wait... which is it? The session closes when you close the window/tab and it closes if the window/tab hasn't been visited for 15 minutes? So even after the session closes, the cookie of the SID doesn't get deleted? All of the sessions gets saved on the server even after it closes? When does it permanently get deleted? Oh okay.
  20. dalawh

    Writing into a file

    Okay. Thanks for the help guys.
  21. dalawh

    Writing into a file

    Oh okay, so it is just how the f__ works. Is there anyway to prevent the .txt file from being accessed through the url? Do I just change the chmod of a folder that it is in?
  22. dalawh

    Session

    I know that, but so does a database. The SID is stored as a cookie and using that cookie, it finds the specific session on the server, so what I tried to ask was why not just use a database instead? Can't I use a database instead, which won't allow a user to edit the information like a session? If so, why not just use a database over a session? I am not looking for the index of the cookie to be used for the session. I am wondering what were the indexes of the session. Are they self defined or are they like cookies, where they are pre-set? Your first sentence confused me. Were you trying to say that the session's cookie lifetime is alive until the browser is closed or closing the tab or going to a different page? Does the cookie get deleted when you close one of the above three options? How long does the session stay alive? After the session closes, and the user returns, it creates a new ID? Is the new ID something that has never been used or does it at one point overlap? Since the server doesn't know who you are, it uses a cookie to match it with the session to figure who you are, can't you just use a cookie and a database instead?
  23. dalawh

    Writing into a file

    That is not what I meant. Sorry for the confusion. What I was trying to ask is that am I able to look at the file through url, meaning if I type the url into the address and hit enter, will the contents appear, if it was set to write only.
  24. dalawh

    Session

    So is there any real reason to use a session? Why not just use a database instead since they both require the server. The session is stored somewhere on the server, which can be found in the php.ini file and the session indexes are defined in the php.ini file. So the session variables, http://w3schools.com/php/php_sessions.asp, were already pre-set in the php.ini and vary from case to case?
  25. dalawh

    Writing into a file

    When you set a file to read and write, I know you can read it using fread, but can you read it using the url (site.com/logs.txt)? Now if you set it to write only, I assume fread does not work right? Does reading it using the url work?
×
×
  • Create New...