Jump to content

Wolphie

Members
  • Posts

    682
  • Joined

  • Last visited

    Never

Posts posted by Wolphie

  1. I think you're looking for an offset. Why not just insert the time that the button was clicked into the database, and then check the current time to see if it's been more than 20 minutes since they hit the button. This is the way I would do it, however if people don't refresh the page for 20 minutes then they wouldn't be updated about the status of their army. Unless you had some kind of automated refreshing function. To do this you should either use an HTTP refresh, javascript refresh or use PHP's header() function (not sure if it's possible with header(), I don't see no reason why not).

     

    
    $offset = 20 * 60; // 20 minutes
    $old_time = 15 * 60 * 60; // 3pm
    $time = time(); // current time
    
    if(($time - $old_time) < $offset) {
     // refresh page...
    }
    
    

  2. Alright, I've been reading quite a lot about astro physics and physics in general, very interesting stuff! I'm sure a lot of people find it interesting too, at least I hope so! :D

     

    Well, something has been bugging me, today I've been reading a lot about 4 dimensional objects (specifically tesseracts aka hypercubes etc..), I understand that a tesseract can have an infinite number of rooms, if that was the purpose, I also know all of the dimensions, they assume that time is the 4th (not proven). But they also say that mass is another dimension, however, does a tesseract have a mass? I mean surely, if it had a mass, it would be huge to have an infinite amount of rooms. I know nobody can say for definite because we don't see in 4 dimensions. But I was just wondering if anybody had an opinion or theory.

  3. Excuse me, but I suggest you read the forums description. This forum is for helping people with the code they already have. Not for people to write it for you, if you want people to write it for you check the Freelance forum out. If you want to actually learn something, rather than people giving you everything then I suggest you make the effort to read and attempt it yourself, and then; only then come back with your code, your problem and your objective asking for help. You got the answer to your question.

  4. I find it easier to give the submit buttons different names rather than passing them along to PHP as an array. If you passed them as an array you would need to validate each value, thereby giving each submit button a different appearance and having to write more code than necessary, whereas giving the submit buttons different names all of the submit buttons could appear the same (if you wanted them to). But regardless, I still find that giving the submit buttons different names easier.

     

    I think form controls such as checkboxes should be passed as an array because then it saves code, rather than having to assign the POST data to individual variables you could just loop through the array or use array keys.

  5. A lot of hosting services have started blocking outgoing email where the FROM header is set to an outside domain. Basically they don't want people to use their servers for phishing.

     

    Understandable, I suppose if I was in their position I wouldn't want it either.

  6. ^ I've had issues on my server sending emails with the "From" header not corresponding to my domain. But it may work for him...

     

    Odd, did you set the server up yourself? I've often had mail problems because of typos in the configuration files.

  7. From what I can make out of you're objective is that you want the user to enter their e-mail address, and you want the e-mail being sent to appear as if it came from the e-mail address they entered? Assuming this is true, you obviously have an input field for them to enter their e-mail address.

     

    From that just do something similar to:

     

    mail("blablabla@gmail.com", "Comment from website", $message, "From:" . $email); // $email being the variable which stores the post data.
    

  8. It sometimes depends on what kind of packages/applications you've installed to set up the server. For example, if you've used a pre-built package they may place it in a different directory. But usually to access phpMyAdmin, just go to http://localhost/phpmyadmin/

     

    It usually has to be accessed using localhost or 127.0.0.1 (which is the same as localhost), for security reasons but you can enable external access.

  9. Also do bear in mind that a lot of shared, re-seller and virtual dedicated hosting plans have prefixes of usually the username which it has been registered with, as Crayon Violent said, however with prefixes, database names you enter tend to get cut off. This has often been my problem in the past, I've known about the database prefixes, however I've sometimes assumed that the whole name I entered would be used which wasn't the case.

     

    On a side note, most web hosting services provide local MySQL servers. And therefore you would need to enter "localhost" for the server address.

     

    e.g.

     

    $con = mysql_connect("localhost", "pcscript", "password123");

  10. I assume that this is an upload script. For a progress bar (which tracks the progress e.g. 10%, 20% etc..) you will need to use JavaScript; however, you cannot use PHP and JavaScript alone to track the progress, you will need to use some other language such as perl or python or java because JavaScript cannot access the file system to see how much of the file is uploaded and with PHP the file has to be completely uploaded in order for it to determine the filesize. Alternatively you could use flash.

  11. <?php
    if($con = mysql_connect('server', 'username', 'password')) 
     mysql_select_db('db_name')
       or die('MySQL Error: ' . mysql_error());
    
    $sql = mysql_query("SELECT * FROM `db_name` . `table_name`", $con)
              or die('MySQL Error: ' . mysql_error());
    
    if(mysql_num_rows($sql) > 0) {
     while($row = mysql_fetch_array($sql)) {
       if($row['field_name'] == 'cat')
         print 'dog';
     }
    }
    
    // Or you can use switch() as zenag suggested.
    
    if(mysql_num_rows($sql) > 0) {
      switch($row['field_name']) {
        case 'cat':
          print 'dog';
          break;
        case 'dog':
          print 'cat';
          break;
        default: 
          print 'cat & dog';
          break;
      }
    }
    
    mysql_close($con);
    ?>
    

×
×
  • 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.