Does anyone do free script writing?

Discussion in 'Programming' started by dragonsmistress, Jan 24, 2009.

  1. #1
    It's something simple... I think but I'm not advanced enough in php to do it ): And I don't have money to pay someone to do it either ): I need to limit users from adding dragons that have less then 3 days to live. My site is a fansite based on dragcave.net. If anyone can help me I'd really appreciate it :)
     
    dragonsmistress, Jan 24, 2009 IP
  2. harrisunderwork

    harrisunderwork Well-Known Member

    Messages:
    1,005
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Great site I must say :)
     
    harrisunderwork, Jan 24, 2009 IP
  3. dragonsmistress

    dragonsmistress Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You know it??? Could you help me?
     
    dragonsmistress, Jan 24, 2009 IP
  4. Dennis M.

    Dennis M. Active Member

    Messages:
    119
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Pardon me for not completely understanding the question, but you could add something as simple as this if statement:

    Please note you'll have to change the database settings obviously as well as the vars and database data. I am not sure how you plan on looking up the dragon (is it within the user's account? In a drop down? or something? ID would be most efficient but in this example I'm going to search by name.) PM me if you need more help.

    
    <?php
    // My assumption is you're using sessions for users?
    session_start();
    
    // Basic MySQL connection unless you have a class/function for it
    mysql_connect("localhost","USER","PASS");
    mysql_select_db("USER_DATABASE");
    
    // Provided that you're using sessions and the dragon name was posted through a user input
    $query = mysql_query("SELECT * from users WHERE user='".mysql_escape_string($_SESSION['username'])."' AND dragon_name='".mysql_escape_string($_POST['dragon_name'])."' LIMIT 1;");
    
    while($row == mysql_fetch_array($query)){
         // Assuming your "lives_remaining" column is where the lives are stored
         $lives = stripslashes($row['lives_remaining']);
    }
    
    if($lives < 3){
         echo("Your dragon must have at least 3 days left to live to be added.");
         exit;
    }
    ?>
    
    PHP:
    Again difficult without knowing the exact situation of everything but that is an example of what you could do!

    Regards,
    Dennis M.
     
    Dennis M., Jan 24, 2009 IP
  5. NinjaWork

    NinjaWork Guest

    Messages:
    132
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    
    if ($dragons < $three_days_to_live) {
        limit_dragons()
    }
    
    Code (markup):
    sorry...I had to do that ;-) great idea for a script!
     
    NinjaWork, Jan 24, 2009 IP