Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Posts posted by hitman6003

  1. Similar to the above, though I kind of think it will be a faster query:

     

    "SELECT viewed_count FROM table ORDER BY viewed_count DESC LIMIT 1"

     

    Depends on how the values are stored in the database.  If every page view == an insert to the table, then your query won't work.  If every page view increments a "views" counter in the database (i.e. each page has a single row in the database which has a counter), then my query won't work.

  2. $dg1 is a resource, so it being equal to "Resource id #4" is normal.

     

    $dg12 is the number of rows returned..."1" means one row was returned.

     

    You didn't get a value returned back for $dtime because mysql is returning the column name back with the name "DATE_FORMAT....".  Either use a numeric index on your result...

     

    while ($row = mysql_fetch_array($dg1)) {
      $dtime = $row[0];
    }

     

    Or, since you have one row, with one column, use mysql_result:

     

    $dtime = mysql_result($result, 0);

     

    Or assign the result column to a different name in the SQL query:

     

    SELECT DATE_FORMAT(dtime, '%m/%d/%y') AS dtime FROM dlg WHERE lname = '$lname'

  3. First, by "it returned zero" do you mean it returned zero rows, or it failed?

     

    Second, your query is probably wrong...you have it enclosed in single quotes, which means it will not do variable substitution...

     

    change

     

    $dql = mysql_query('SELECT DATE_FORMAT(dtime, "%m/%d/%y") FROM dlg WHERE lname = "$lname"');

     

    to

     

    $dql = mysql_query("SELECT DATE_FORMAT(dtime, '%m/%d/%y') FROM dlg WHERE lname = '$lname'");

     

    Notice I changed double quotes to single, and single to double.

  4. What is the name of the "submit" button on the form?  For example:

     

    <input type="submit" name="this_is_what_I_want" value="Submit" />

     

    That value is what shoule be in your if statement...in this example:

     

    if (isset($_POST['this_is_what_I_want'])) { ... }

  5. Use MySQL's DATE_FORMAT function.

     

    The php date function expects a unix timestamp (seconds since epoc).  However, MySQL is outputting a string representation of the date.  You can either change the format in MySQL (using the DATE_FORMAT function), or you can use MySQL's UNIX_TIMESTAMP function to convert it to that format and then format the final in php.

     

    I recommend the former:

     

    SELECT DATE_FORMAT(dtime, "%m/%d/%y %g:%i %A") FROM table_name

     

    I'm not 100% sure that the format string is correct however (I didn't look up the format).

     

    http://www.mysql.com/date_format

  6. Just as your provider states, you need to provide the additional parameter to the mail function:

     

     @mail ( $cgi->getValue ( "adminemailaddress" ), $yoursubject, $emailtext, "From: " . $cgi->getValue ( "email" ), "-fyourmail@yourdomain.whatever" ); 

     

    If the author hasn't heard of it before tell him/her to go read the manual:  http://www.php.net/function.mail, example 3.

     

    The options that can be provided in this manner are found in the sendmail man page:

     

    http://www.sendmail.org/~ca/email/man/sendmail.html (or "man sendmail" from the command line)

     

    In particular, the "-f" states:

     

        -fname      Sets the name of the ``from'' person (i.e., the sender of the

                    mail).  -f can only be used by ``trusted'' users (normally

                    root, daemon, and network) or if the person you are trying to

                    become is the same as the person you are.

  7. A for loop is easier:

     

    for ($i = 1; $i <= 10; $i++) {
      echo $_POST['name' . $i];
    }

     

    However, it is probably even easier to use a different method of gathering the data:

     

    <INPUT type=checkbox value=Yes name="userdata[1][checkbox]">
    <INPUT  size=42 name="userdata[1][name]">
    <INPUT  size=42 name="userdata[1][phone]">
    <INPUT  size=42 name="userdata[1][address]">
    
    <INPUT type=checkbox value=Yes name="userdata[2][checkbox]">
    <INPUT  size=42 name="userdata[2][name]">
    <INPUT  size=42 name="userdata[2][phone]">
    <INPUT  size=42 name="userdata[2][address]">
    
    <INPUT type=checkbox value=Yes name="userdata[3][checkbox]">
    <INPUT  size=42 name="userdata[3][name]">
    <INPUT  size=42 name="userdata[3][phone]">
    <INPUT  size=42 name="userdata[3][address]">

     

    You would end up with a multidimenstional array in post:

     

    foreach ($_POST['userdata'] as $number => $data) {
      echo $data['name'];
    }

  8. The thing that worries me is insecure passwords. Dictionary-based tables are publicly available

     

    Exactly...it doesn't matter (for the most part) the hash or encryption if the password is weak to begin with.

     

    On a side note, md5 is a 128 bit hash, which means there is 2^128 number of values.  According to the calculator on my Fedora 8 laptop, that comes to ~ 3.4*10^38 combinations.

     

    MySQL's largest integer data type is BIGINT, which according to their documentation, and unsigned BIGINT has a max value of 18446744073709551615. 

     

    If you divide the first number (2^128) by the second, you get 18446744073709551617.  This means it would take 18,446,744,073,709,551,617 mysql tables, all with a BIGINT primary key, to find every hash possible.

     

    Terabytes is still a very small percentage.

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