Jump to content

Fehnris

Members
  • Posts

    46
  • Joined

  • Last visited

Posts posted by Fehnris

  1. Javascript is a clientside language meaning that the code runs when the person loads and views your website.  The code runs in the clients browser.

    PHP is a serverside language meaning that when someone requests the web page the code is executed on the server before the page has even left for the clients browser.

     

    What you are trying to do won't work for several reasons.

    1) you are using PHP to try to increment the resolution value of the browser

    The PHP code is executed 'before' it reaches the browser and so the resolution of the browser isn't available to the PHP code.

     

    2) you are trying to increment a variable that isn't a number.

    The php variable $width doesn't contain a number but instead contains all your Javascript code.  Because of this the variable doesn't contain 1280.

     

    Your page does as you say display 1280 but this is all done by the Javascript.  All your PHP code is doing is effectively outputting your Javascript which is then sent to the browser where is it ran to display the resolution.

     

    To accomplish what you need, you should look into writing it all with Javascript.

  2. Im not sure if its going to make a difference but you are trying to compare an integer in your array to the $_GET['id'] value which is more than likely a string.  You could try adding intval() to your $_GET['id'] value to convert the GET value from string to integer before the comparison takes place like:-

     

    
    if(isset($array1[intval($_GET['id'])])) {
    
    * do something *  
    
    

  3. Yes just write a normal PHP script like one you would make for a webpage, but without any HTML or output, for example no echo statements.

     

    It really depends on what limitations on keeping the profile view records, you want to impose on the database.  For example do you want to only limit the amount of stored views per profile to 10 views or do you want to remove profile views that are older than a certain amount of time? 

     

    If you were to have a script that limits profile views to 10 per profile, you would need to have a while loop to get all your profiles seperately then get all views from that profile and select the newest 10 to keep and delete the rest. 

     

    Alternatively if you wanted to only allow profile views to stay in your database until they reach a certain age.  You could simply get all the profile views that are older than a specified date and delete all these records.

     

    All you would need to do is setup a Cron for this script to run when ever you wanted it to, every 24 hours if you prefer.

  4. Your welcome :)  You would incorporate them in with your while loop for each record for example:-

     

    
    echo "<table>";
    while($row=mysql_fetch_array($result))
    {
       echo "<tr>"; 
       
       echo "<td>";
       echo "<input type='checkbox' name='maybe the id of this record to allow you to identify if a certain row is checked'>";
       echo "</td>";
       
       echo "<td>";
       echo $row['field1'];
       echo "</td>";
       .
       etc
       .
       echo "</tr>";
    }
    echo "</table>";
    
    

  5. Assuming that your PHP file out puts the results in some formatted way using HTML, simply add the PHP file name to the src attribute of your IFRAME tag:-

     

    
    <iframe 
    src ="your PHP file that gets database records.php"
    width="100%">
    </iframe>
    
    

  6. PHP isn't going to be concerned with the table layout.  Sure you will need PHP to connect and retrieve your database records but for the actual formatting of the table as in the link you provided, you will need to use HTML.  For there table layout they have used DIV tags but you could do something similar using HTML Table, TR and TD tags.

     

    If you are using a MYSQL database and you decide on HTML tables, you could do something like:-

     

    
    echo "<table>";
    while($row = mysql_fetch_array($result))
    {
    echo "<tr>";
    
    echo "<td>";
    echo $row['field1'];
    echo "</td>";
    
    echo "<td>";
    echo $row['field2'];
    echo "</td>";
    .
    etc.
    .
    echo "</tr>";
    }
    echo "</table>";
    
    

     

    This would only give you the basic layout and you would also have to consider styling your tables using different TABLE tag attributes straight in each tag or by adding extra values to your CSS documents.

  7. If you want to check what they have entered before the form gets submitted you will have to use some form of client side script language ie. Javascript, VBscript to do the checking.  I assume DW means Dreamweaver and I've not had any experience using it so I dont know what Client Side languages you can use with it.  PHP is server side and so will not have the ability to check your form values before the form gets submitted.

  8. You dont really want to be checking that $check isnt equal to zero.

     

    
    if ($check != 0 )
          {
          $query="INSERT INTO seebergerLogin (username, password, first_name, last_name)VALUES       ('$_POST[email_address]','$_POST[password]','$_POST[first_name]','$_POST[last_name]')";   
          
          $_POST[password] = md5($_POST[password]);
          
        echo $fname;
        echo ', your account has been created 
    ';
        echo "<html> <body> To Sign into your account <a href='loginsql.php'> Click Here![/url]";
          }
    
    
    

     

    Instead check it like this.

     

    
    if (mysql_num_rows($check) > 0 )
          {
          $query="INSERT INTO seebergerLogin (username, password, first_name, last_name)VALUES       ('$_POST[email_address]','$_POST[password]','$_POST[first_name]','$_POST[last_name]')";   
          
          $_POST[password] = md5($_POST[password]);
          
        echo $fname;
        echo ', your account has been created 
    ';
        echo "<html> <body> To Sign into your account <a href='loginsql.php'> Click Here![/url]";
          }
    
    
    

  9. The switch statement as Moon-Man.net stated is definately another possibly better way to go than the if/elseif.  Your code says at the bottom "this part I cannot get working".  In what way does it not work?  Does it give error messages or does it produce something different than you want?

  10. So the code line '$res=mysql_query("update $tbl_members set enabled='yes' where login='$login' ");' isnt updating the database record for the current user? Try putting 'or die("MYSQL update error.".mysql_error());' at the end of the line to see if you get an error for the mysql_query. If its not updating the current users database record, its more than like going to be the update query that isnt working correctly.  By putting the or die statement at the end, you will be able to find out why the query isnt working.

     

  11. First off, to have a webserver, you really need some 'Static' way of addressing it.  Be it a Domain Name or a Static IP address.  As you only have a Dynamic IP address assigned from your ISP you would need to do one of 2 things.

    1. See if your ISP can provide a Static IP address instead of a Dynamic one (Would probably involve extra cost per month).
    2. Check to see if your Router supports DDNS.  If it does you can register with someone like this [url=http://www.DynDNS.org]www.DynDNS.org[/url] which would give you a domain name that would follow your dynamic IP address.

    Thats the first thing to consider.  The second is to configure your router to:-

    1. Let incoming connections from the internet through your router (port 80 for webserver) to 'your' PC.
    2. Setup static IP addresses on your router for at least 'your' PC and point your router's incoming http requests to your PC's IP address (port forwarding).

    Thirdly, (not sure if you already have this covered as you said you have created your home page) you need to have some webserver software installed on your PC to host your site.  Apache is a good one and you can download it for Linux/Windows.

    Other things to consider, your internet connection, how busy you expect your webserver to be and network security.

    Most internet connections are slower uploading than downloading (typical 1mb DSL download = 256kb upload).  Since you are wanting to 'Serve' webpages your upload bandwidth needs to be taken into consideration.  Having a busy website on slow upload will impact on your connection from any of your LAN PC's to and from the Internet. They would need to share the connection bandwidth with anyone requesting a webpage from your home webserver.

    There is also the issue of security. By having a webserver and a way 'in' from the internet to your home network, increases your risk for security breaches to yours and other PCs on your home network.

    Hope that bit of rambling has been of some help  :)
  12. I can't see a solution to you being able to compare the two entries because as you say all you have to work with is times and no dates. 

    If the file is writen to sequentially then chances are the second entry time is closer to the present than the first entry time. 

    Thats about all the information you can get from it.  No way of telling, that I can think of, if the second time is the same day, the next day or the next week.  Only indication of the second time being not the same day would be if the second time is earlier than the first.

    I had an idea of maybe checking the log file with filemtime() to get the last time the file was edited, but all that will tell you is the date/time the last entry was added to the log file.  That would still leave you with the problem of figuring out a date for the first entry to compare the two dates.

    What level of access do you have to the log file creation?  i.e do you have a say in what format to save the date/time to the log file?  If so I would suggest the date/time, for future entries to include date and time in some format.  Sorry I can't be of more help.
  13. Yeah very possibly part of the superglobal or session variables.  PHP has both of these although to have PHP automatically register superglobals you need to either be running a version of PHP less than 4.3 something.  Any version above that you have to enable the automatic registering as a setting in your config file. 

    You could check to see what version of PHP you are running and also how your register superglobals option is set.  If its enabled then quite possibly these variables are session/superglobal variables.
  14. Sure shouldn't be to difficult.  Something like the following should suffice. (Im assuming your database is a mysql database).

    [code]

    $con = mysql_connect ("$HOST", "$USERNAME", "$PASSWORD") or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("$DATABASENAME");

    $sqlquerystring = "SELECT * From 'insert your table that has the date fields here'";
    $sqlresult = mysql_query("$sqlquerystring") or die ('sqlquerystring error: ' . mysql_error());

    while($tablerow = mysql_fetch_array($sqlresult))
    {

      $date = $tablerow['insert your date database field here'];
      $time = $tablerow['insert your time database field here'];

      $year = substr(strval($date), 0, 4);
      $month = substr(strval($date), 4, 2);
      $day = substr(strval($date), 6, 2);
      $hour = (int) substr($time, 0, 2);
      $minute = substr($time, 3, 2);

      $timestamp = mktime($hour, $minute, 0, $month, $day, $year);

      //Hopefully you have an 'id' field in your database table that is set to auto increment.  The record update string below relies on the
      //fact that an id field is present to determine which record to update in the database.

      $sqlupdatestring = "Update 'insert your database table name here' Set 'name of new timestamp field'=$timestamp where id=".$tablerow[id];

      $result = mysql_query("$sqlupdatestring") or die ('sqlupdatestring error: ' . mysql_error());

    }

    [/code]

    Hope that helps

  15. Would save yourself some work when testing for a banned date by using a UNIX timestamp to save the ban expiry date in the database.

    [quote]X minutes, X Hours, X Days, -> X being any value, could
    be 1 minute or2348 minutes... etc.[/quote]

    Im pressuming when the Mod enters X minutes, X hours, X days these values get passed to a script that creates a ban date for an account in the format "j, m, Y - H:i.s" and enters it into the database.  When creating the ban expiry date use strtotime() to create a timestamp instead:-

    $BanTimeStamp = strtotime("+"."<X Days>"." days "."<X Hours>"." hours "."<X Minutes>"." minutes "."<X Seconds>"." seconds".

    Using Unix timestamps in your database you could simplify your ban checking script to:-

    [code]

    if($ban=="y")
    {
      $SQL = mysql_query("SELECT * FROM ban WHERE user='".strtolower( $_POST['user'] )."'");
      while( $data = mysql_fetch_row( $SQL ))
    {

        // get current timestamp
        $today = time();

        //No more need to convert from your string date format to Unix timestamp for comparing as
        //Data[4] is already in UNIX timestamp format.

        //compare the timestamps
        if( $today >= $Data[4] )

    {



    [/code]
  16. Sorry for the slow response, cron jobs are usually something provided as part of your web host control panel.  My webhost has cPanel which has an icon for Cron Jobs.  Check with iPower to see whether and how they offer Cron Jobs.
  17. Using substr() easiest way I can think of:-

    [url=http://us3.php.net/substr]http://us3.php.net/substr[/url]

    Code below converts your old date format to the new mysql date format. (Im pressuming that your old date format is MM/DD/YYYY - wasnt specified in your post just 00/00/0000)

    [code]

    $mysqldate = substr(<your old date here>, 6, 4)."-".substr(<your old date here>, 0, 2)."-".substr(<your old date here>, 3, 2);

    [/code]

    Code below converts your mysql date format back into the old date format. (MM/DD/YYYY pressumably)

    [code]

    $olddateformat = substr(<your mysql date here>, 5, 2)."/".substr(<your mysql date here>, 8, 2)."/".substr(<your mysql date here>, 0, 4);

    [/code]
×
×
  • 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.