Jump to content

Nodral

Members
  • Posts

    397
  • Joined

  • Last visited

Posts posted by Nodral

  1. To make this easier,

     

    Change your date format to a Unix timestamp, then you can create a script which will take today's date and subtract 5 days from it (call it $date_calc or something similr).  Then you would do something like

     

    //get the values from the table which are 5 days old or younger.
    $sql="SELECT close FROM tablename WHERE date > $date_calc";
    //run sql query
    $sql=mysql_query($sql);
    while($row=mysql_fetch_array($sql)){
    
    //add the last 5 into an array
    $close_total[]=$row[close];
    }
    
    //calculate the average of the array
    $output=(array_sum($close_total))/5
    
    //then do what every you want with $output
    

  2. Since 2007, things have changed  :(

    • CAMP is now a personality trait rather than a hobby involving tents
    • DAMP is now an issue with my house rather than a state my wife gets when we're together
    • VAMP is now a fashion statement rather than a series of characters Bram Stoker's novels

  3. Whichever appears latter in the code will override the others.

     

    Your process should be something like

    if (isset($_POST['password'])){
    .
    .
    .
    .
    .
    .
    $password=md5( md5($salt.$_POST['password']));
    .
    .
    .
    .
    .
    .
    .
    either INSERT or SELECT with DB using $password
    .
    .
    .
    .
    .
    .
    .
    <form method="post" >
    <input type="password" name="password">
    

    You shouldn't need to define it any more times than this really.

     

    Your user will input in either a reg form or login form

    This is then returned to the script as $_POST['password']

    This will then be hashed and salted to $password

    Which is then either written to DB or used as part of a SELECT statement to get existing user details.

     

    Have a scan through your code and see if it fits to this, if you've got other complications in there (except the bit to prevent numeric SQL injection) you may want to remove them.

     

    Hope this makes sense

     

  4. Read the post by kikesv.  He has already shown how to do this.

     

    What's the point of posting on here if you don't read, digest and try to understand what people are doing to help?

     

    You may want to do a bit of Googling about basic MySQL databases and the fundamental statements and interactions that php has with it.

  5. Ok

     

    Somewhere along the line, you have to change $_POST['password'] into $password.

     

    If we refer back to code in previous posts, this line has got distorted.  What you acteully are trying to do is take $_POST['password'] hash it and salt it and then call it $password to be used when interacting with your DB

     

    change

    $salt="Any random gobbldy-gook";
    $password=md5( md5($salt.$password));
    

     

    to

    $salt="Any random gobbldy-gook";
    $password=md5( md5($salt.$_POST['password']));
    

     

     

    This needs to be the same wherever you refer to $password or $_POST['password']

     

  6. Possibly want to use

    mysql_query($query) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
    

     

    Then if you have got issues, it will tell you.

     

     

  7. Read through your original code that you posted in your question.

     

    At no point in this code do you have either an INSERT or UPDATE statement.  How can you expect to transfer information to a DB without actually having the commands in your script that will do this for you????????

     

    That's like me thinking of a number and then asking you what it is.  You won't know, because I've not transferred that information from my brain to yours via my mouth!!!!!

  8. Do all your functions and processing, etc outside of your query statement, then insert it as a variable.

     

    e.g.

    $loginUsername = "admin";
    $loginUsername=mysql_real_escape_string($loginUsername);
    mysql_select_db($database_uploader, $uploader);
    $query = sprintf("SELECT * FROM members WHERE uname='%s'", $loginUsername);
    mysql_query($query);
    

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