Jump to content

Don E

Members
  • Posts

    996
  • Joined

  • Last visited

Posts posted by Don E

  1. Do you make any use of session.gc_maxlifetime...in the way I describe it?

    Just to note in regards to session.gc_maxlifetime that I discovered about sessions in-depth this past weekend, adjusting session.gc_maxlifetime does not necessarily mean that the session will last that amount of time. Here is a quote from the following link about session.gc_maxlifetime: http://http://stackoverflow.com/questions/1516266/how-long-will-my-session-last

    In general you can say session.gc_maxlifetime specifies the maximum lifetime since the last change of your session data (not the last time session_start was called!). But PHP’s session handling is a little bit more complicated.

     

    Because the session data is removed by a garbage collector that is only called by session_start with a probability of session.gc_probability devided by session.gc_divisor. The default values are 1 and 100, so the garbage collector is only started in only 1% of all session_start calls. That means even if the the session is already timed out in theory (the session data had been changed more than session.gc_maxlifetime seconds ago), the session data can be used longer than that.

     

  2. Yes, you use this function:http://php.net/manual/en/function.session-set-save-handler.phpIt's not a good idea to use the mysql extension at this point though, you're better off using PDO.

     

    Is mysqli okay? I'm sure it is but I assume you mentioned that because the article is written using the mysql extension and it's no longer recommended to use the mysql extension but just to ask, is mysqli still okay even though its not as portable as PDO?

     

    Thanks.

  3. Hello everyone,

     

    I've done some search into the following but not sure what is the best route to take regarding sessions.

     

    If I have a cron job to do something at a certain time of the day, like delete files to free up space etc, what would be recommended to not have the cronjob delete the files where the file names of those files are stored in session for that user whose session is currently active?

     

    There is a session_status function which checks if any sessions are active but that is only for PHP 5.4 and up.

     

    Thanks.

  4. Are you checking/getting any mysql errors anywhere? Just to note, it's recommended to use MySQLi instead of mysql.

     

    May not be the reason why but looks like you're missing a single quote for $post_title for the values in your mysql query. It's '$post_title

    Also make sure you're columns spelled correctly.

  5. Is the page saved with .php extension? Is/was php and apache updated with no problems/errors? If all is fine with those, then do you have anything running on the server like a security program working with apache that might cause that?

     

    Checking logs/error logs could maybe help you see what's going on as well.

  6. I'll try and illustrate: Per user that visits, when you have session_start(), a "session" is started/created for that user. So if any session variables are set like: $_SESSION['username'] or/and $_SESSION['loginStatus'], those variables contain values that are distinct for that user during his/her "session".

     

    So, you can say for example for "user's login session" like this: 'What is the users' login STATUS, which the status is stored in the variable $_SESSION['loginStatus'] for the current "session" for that user, that was started by session_start() ?'

     

    Hope this understands.

  7. echo prints out what htmlspecialchars (a function in PHP) returns from when you pass $_SERVER['PHP_SELF'] to it.

     

    $_SERVER['PHP_SELF'] contains the current file name. For the action attribute, you may be able to just write into the action the name of the page instead of doing the whole php echo.

  8. Try and change your pattern namecheck to the following:

    namecheck = /[A-Z,a-z]+s[A-Z,a-z]+/;

    That looks for letters, a space, and letters only. For i.e.: John Smith, like how names are. If anything that is entered that is not a match to that, it returns false.

    if(fnlname.value == ''){    fulname.innerHTML = '<b>full name is missing</b>';    return false;}else{   if(!namecheck.test(fnlname.value)) //if anything doesn't match the pattern above, test() returns false. So in other words, if it is TRUE that test() returns false, enter the if    {      fulname.innerHTML = '<b>Both Names Required</b>';      return false;     }}

    If the user entered a pattern match for namecheck/test(), when the script reaches this point:

    if(namecheck.test(fnlname)){  fulname.innerHTML = '<b>checked</b>';   return false; }

    ... since test returns true, we should enter this if and set the innerHTML of fulname to <b>checked</b>.

     

    Hopefully this was of some help.

  9. In PHP, the dot is the concatenation operator. See this link: http://www.w3schools.com/php/php_operators.asp ...scroll down to String Operators.

     

    If you don't want to use the dot operator to concatenate, you can use double quotes with the variable included like the following: echo "My eye color is $color"; Because of being in double quotes, PHP displays(parses) the value of the variable $color. The output is: My eye color is green.

  10. Those aren't necessarily methods but properties actually. They are properties of that particular element. An HTML element is actually an object - an object has properties and methods(functions). .innerHTML, value, etc are properties for example of a particular element that you can reference to by using document.getElementById('myElement' ); getElementById() is actually a method for the 'document' object.

  11. In the else if condition, you can use && (and) to check if numapples is greater than 1 and less than 4. For example:

    else if(numapples > 1 && numapples < 4) 

    If numapples is greater than 1 and less than 4, the else if is executed.

  12. Try adding <script src="myscript.js" type="text/javascript"></script> after <p id="demo"></p> and it should work. The script runs before the html page finishes loading.

     

    For your myscript.js file to access HTML elements once the page has loaded, add the following to myscript.js and leave the script in the head section of the html page and you should see "Hello World!' in the p elements' innerHTML displayed:

    // this assigns a function to the window.onload event and the function runs once the page has loaded.window.onload = function init() {     window.alert("Hello World");     document.getElementById("demo").innerHTML = "Hello World!";}
    • Like 1
  13. I'd use a text editor specifically designed for writing code like HTML, CSS, JavaScript etc instead of plain notepad. There are plenty of good free ones out there. Using a text editor is helpful in properly setting up and saving your files to the right extension for example in order to run properly.

     

    Other than that, I see you have spaces before and after your equal signs. Not entirely sure this matters. Try having them like this instead: id="leaders"

  14. Usually most host services allow you to manage that particular domain with them at a free cost if you decide to leave that host for the hosting of your site. They also usually give you the option to transfer it to the new host if you want.

     

    Personally I would transfer it to the new host so that you can manage and do everything in one place.

×
×
  • Create New...