Jump to content

Leovenous

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Posts posted by Leovenous

  1. Yep. That worked, and it makes sense. I wonder why I have not been able to find examples of queries even similar. (shrugs)

    Thanks a bunch guys. Here's the final query:

    [code]$query = "SELECT * FROM players WHERE Creator_ID LIKE '$id' AND modified >= CURDATE( ) - INTERVAL 7 DAY";[/code]
  2. I would think this is both a common and easy question, but 2 hours of digging have not yielded any results yet, so here goes.

    All I want, is a simple query to get data from a table that has been modified in the last 7 days.

    I have a field called 'modified' that has a time stamp 0000-00-00 00-00-00. It seems to me I want a way to check the timestamps and grab which ones are less than 7 days old.

    So the query might look something like:

    [code]SELECT * FROM players WHERE modified  > (SUBDATE(CURDATE(), INTERVAL '7' DAY)[/code]

    But obviously I'm bumping around in the dark.

    Any help?
  3. This is probably one of thos "duh" moments, but I've worked my mind into a scramble so an outsider might point out my blindness.

    This is a processing page for a form. It takes information A, and checks to see if there is a B, C, D, F, and G. That dictates what all it needs to insert into the database. As it is now, it inserts that basic (player info) fine. The first insert query works. Its at the end, the pitcher option where it hangs. Its in a secure phpBB enviornment so you can't go to it, but I think its a pretty straightforward script.

    The second query needs to insert the ID that is generated by auto_increment in the initial query. This is not complete, right now, because I'm trying to keep it simple. But eventually it will have to do up to 6 queries after the initial one, using the ID to relate them. That may be the sticking place. I don't know.

    [code]
    <?php
    session_start();
    header("Cache-control: private"); //IE 6 Fix
    define('IN_PHPBB', true);
    include "includes/functions.php";

    // Start phpBB Session
    // phpbbsession();

    $phpbb_root_path = '../forum/';
    include($phpbb_root_path . 'extension.inc');
    include($phpbb_root_path . 'common.'.$phpEx);

    //
    // Start session management
    //
    $userdata = session_pagestart($user_ip, PAGE_MVPTIPS);
    init_userprefs($userdata);
    //
    // End session management
    //

    // Make sure they belong here
    //validate();
    // CHECK if user is logged in
    if (!$userdata['session_logged_in']) { 
        header ("Location: http://www.fanfaregames.com/forum/login.php");
      exit();
    }
    // CHECK to see if they are in the FRC
    // Establish database connection
    require_once('../../scripts/mysql_connect.php');
    // Make a variable for comparison
    $userid = $userdata['user_id'];
    // Query the database on the ID of the user
    $query = "SELECT frc_id FROM frc_users WHERE frc_id = '$userid' ";
    $result = mysql_query ($query) or die(mysql_error());
    // Check if they are legit
    if(mysql_num_rows($result)<1) {
    header ("Location: http://www.fanfaregames.com/frc/denied.php");
    exit();
    }
    $active_game = $_GET['emag'];
    // ***END STANDARD STUFF***

    // Get POST's into variables
    $fname = $_POST['Fname'];
    $lname = $_POST['Lname'];
    $team = $_POST['Team'];
    $dob = $_POST['DOB'];
    $pos = $_POST['Pos'];
    $bathrow = $_POST['Bathrow'];
    $careerpotential = $_POST['careerpotential'];
    $dittytype = $_POST['batterdittytype'];
    $number = $_POST['Number'];

    // Check for pitcher data
    if ($_POST['Pos'] == "SP" || $_POST['Pos'] == "RP") {
    $windup = $_POST['Wstyle'];
    $stamina = $_POST['Stam'];
    $pickoff = $_POST['Pick'];

    // Theyre'll always be a first pitch
    $type1 = $_POST['Type1'];
    $movement1 = $_POST['Movmt1'];
    $control1 = $_POST['Cntrl1'];
    $velocity1 = $_POST['Velo1'];

    // Check for a second pitch
    if ($_POST['Type2']) {
    $type2 = $_POST['Type2'];
    $movement2 = $_POST['Movmt2'];
    $control2 = $_POST['Cntrl2'];
    $velocity2 = $_POST['Velo2'];
    }
    // Check for a third pitch
    if ($_POST['Type3']) {
    $type3 = $_POST['Type3'];
    $movement3 = $_POST['Movmt3'];
    $control3 = $_POST['Cntrl3'];
    $velocity3 = $_POST['Velo3'];
    }
    // Check for a fourth pitch
    if ($_POST['Type4']) {
    $type4 = $_POST['Type4'];
    $movement4 = $_POST['Movmt4'];
    $control4 = $_POST['Cntrl4'];
    $velocity4 = $_POST['Velo4'];
    }
    // Check for a fifth pitch
    if ($_POST['Type5']) {
    $type5 = $_POST['Type5'];
    $movement5 = $_POST['Movmt5'];
    $control5 = $_POST['Cntrl5'];
    $velocity5 = $_POST['Velo5'];
    }
    }
    // Verify the data is present
    if ($fname && $lname && $team && $dob && $pos && $bathrow && $careerpotential && $dittytype && $number) {

    // Do the insert query
    $query2 = "INSERT INTO mvp05_players (ID, Fname, Lname, Team, DOB, Pos, Batthrows, Carpotent, Ditty, Number, Creator_ID) VALUES (NULL, '$fname', '$lname', '$team', '$dob', '$pos', '$bathrow', '$careerpotential', '$dittytype', '$number', '$user_id')";
    $result2 = mysql_query($query2) or die("Error: " . mysql_error());
    if (mysql_affected_rows() == 1) {
    // echo '<p><b>New Player Submitted</b></p>';
    // exit();


    // Check to see if we need to submit pitcher stuff
    if ($_POST['Pos'] == "SP" || $_POST['Pos'] == "RP") {
    $query3 = "INSERT INTO mvp05_pitchers (ID, delivery, stamina, pickoff) VALUES (LAST_INSERT_ID, $windup, $stamina, $pickoff)";
    $result3 = mysql_query($query3) or die("Error: " . mysql_error());
    if (mysql_affected_rows() == 1) {
    header ("Location: http://www.fanfaregames.com/frc/verifypitcher.php");
      exit();
    }
    } else {
    header ("Location: http://www.fanfaregames.com/frc/verify.php");
      exit();
    }
    } else {
    echo 'There has been an error submitting this player. Contact Leovenous.';
    }
    }
    ?>
    [/code]
  4. That much I get. I guess I was hoping there was something like Flash Actionscripts onClick thing. Where clicking the link will perform code before the browser follows the new URL.

    Like:

    onClick() {
        do this
        do that
        do the other thing
        Go to link destination
    }

    Maybe thats just a pipe dream because, if I understand it right, php has no way to continue processing code (as javascript would) once the page is loaded and the initial scripts run.
  5. Howdy,

    I've come across a few situation where, at least my tiny little mind thinks, that it would be useful for your typical link, like:

    [code]printf("<p><a href='index.php?emag=mvp05'>MVP Baseball '05 CP</a></p>");[/code]

    ...to be able to set a session variable either in addition to, or instead of the modifiers at the end of the URL. Is there any way to do this, or just keep working with the URL?

    Thanks.
  6. I don't know how much php is involved. This may belong in the SQL area.

    Anyway, this frusterates me. Its not unusual for me to encounter resource id issues and hours of searching has yielded very little result. Maybe I have a wrong approach or something, I would like to learn.

    So this query:

    [code]$query = "SELECT frc_id FROM frc_users WHERE frc_id = '$userid' ";
    $result = mysql_query ($query) or die(mysql_error());
    echo $query;    
    echo $result;[/code]

    I get the right query:

    [code]SELECT frc_id FROM frc_users WHERE frc_id='2'[/code]

    But the result is the resource id #18. What gives?
×
×
  • 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.