Jump to content

bschultz

Members
  • Posts

    486
  • Joined

  • Last visited

Posts posted by bschultz

  1. There is no cookie...the session ends when the user closes the browser so there is no logout feature.  I'm trying to authenticate people to a subscription to a college sports play-by-play audio stream.  Games can be 3 1/2 hours...makes it hard to log someone out without their interaction.

  2. Hi,

     

    I have a php authentication script that checks against a MySQl database for login info.  Upon a correct login, a session is started.  Is there anyway to limit the authentication to one username at a time?  So that when user1 logs in...and someone else tries to use user1's username and password to access the page as well, it doesn't authenticate, or start the session.

     

    Thanks.

     

  3. The format of the cart DB is 2007-06-07 06:12:33

     

    So, with that code

    date_purchased >= 'CURRENT_DATE():00:00:00' and date_purchased <= 'CURRENT_DATE():23:59:59;'";

    I'm trying to check that if the person has purchased the "single game ticket" today, they would be authenticated

     

    Thanks for the help!

  4. I tried to just test the query for the "single day ticket".  I changed the CURDATE to CURRENT_DATE:  Still turns up false:

     

    <?php
    session_start();
    
    $conn1 = mysql_connect(localhost,xxx,xxx);
    
    if (!$conn1) {
       echo "Unable to connect to DB: " . mysql_error();
       exit;
    }
    
    if (!mysql_select_db("cart")) {
       echo "Unable to select mydbname: " . mysql_error();
       exit;
    }
    $sql1 = "SELECT customers_email_address, date_purchased, order_total FROM orders WHERE customers_email_address = '$_POST[myemail]' AND order_total = '5.00' AND date_purchased >= 'CURRENT_DATE():00:00:00' and date_purchased <= 'CURRENT_DATE():23:59:59;'";
    
    $result1 = mysql_query($sql1);
    
    if (!$result1) {
       echo "Could not successfully run query ($sql1) from DB: " . mysql_error();
       exit;
    }
    
    if (mysql_num_rows($result1) == 0) {
       
    //echo '<meta http-equiv=Refresh content=1;url="error.php">';
    echo "You are not subscribed to the Season Ticket...but I'll check to see if your ticket is for today's game<br><br>";
       
    }
    
    
    while ($row1 = mysql_fetch_assoc($result1)) {
    
    
    echo "Your season ticket is valid...enjoy the game...<meta http-equiv=Refresh content=1;url='listen2.php'>";   
    }
    
    
    mysql_free_result($result1);
    
    
    ?>
    

  5. OK...I split this into 2 queries...and it still turns up false...I've even tried removing the CURDATE reference in the 2nd query for testing purposes, and it still turns up false.

     

    <?php
    session_start();
    
    $conn1 = mysql_connect(localhost,xxx,xxx);
    
    if (!$conn1) {
       echo "Unable to connect to DB: " . mysql_error();
       exit;
    }
    
    if (!mysql_select_db("cart")) {
       echo "Unable to select mydbname: " . mysql_error();
       exit;
    }
    $sql1 = "SELECT customers_email_address, date_purchased, order_total FROM orders WHERE customers_email_address = '$_POST[myemail]' AND order_total = '75.00'";
    
    $result1 = mysql_query($sql1);
    
    if (!$result1) {
       echo "Could not successfully run query ($sql1) from DB: " . mysql_error();
       exit;
    }
    
    if (mysql_num_rows($result1) == 0) {
       
    //echo '<meta http-equiv=Refresh content=1;url="error.php">';
    echo "You are not subscribed to the Season Ticket...but I'll check to see if your ticket is for today's game<br><br>";
       
    }
    
    
    while ($row1 = mysql_fetch_assoc($result1)) {
    
    
    echo "Your season ticket is valid...enjoy the game...<meta http-equiv=Refresh content=1;url='listen2.php'>";   
    }
    
    
    mysql_free_result($result1);
    
    
    $sql2 = "SELECT customers_email_address, date_purchased, order_total FROM orders WHERE customers_email_address = '$_POST[myemail]' AND order_total = '5.00' AND date_purchased = CURDATE";
    
    $result2 = mysql_query($sql1);
    
    if (!$result2) {
       echo "Could not successfully run query ($sql2) from DB: " . mysql_error();
       exit;
    }
    
    if (mysql_num_rows($result2) == 0) {
       
    //echo '<meta http-equiv=Refresh content=1;url="error.php">';
    echo "You are not subscribed to the daily ticket for today...please purchase one to listen.  I'll redirect you soon... <meta http-equiv=Refresh content=10;url='/shop/'>";
       
    }
    
    
    while ($row2 = mysql_fetch_assoc($result2)) {
    
    
    echo "Your single day ticket is valid...enjoy the game...<meta http-equiv=Refresh content=1;url='listen2.php'>";   
    }
    
    
    mysql_free_result($result2);
    
    ?>
    

  6. CURDATE is a MySQL function...like I said in my original post, I didn't know how to change the date in the cart DB to strip the time...I was trying to see what CURDATE would return.

     

    As for the rest of your suggestion, that seemed to work...but I must not be writing this correctly, because it didn't return the results I wanted.

     

    <?php
    
    $conn1 = mysql_connect(localhost,xxx,xxx);
    
    if (!$conn1) {
       echo "Unable to connect to DB: " . mysql_error();
       exit;
    }
    
    if (!mysql_select_db("cart")) {
       echo "Unable to select mydbname: " . mysql_error();
       exit;
    }
    $sql1 = "SELECT customers_email_address, date_purchased, order_total FROM orders WHERE customers_email_address = '$_POST[myemail]'";
    
    $result1 = mysql_query($sql1);
    
    if (!$result1) {
       echo "Could not successfully run query ($sql1) from DB: " . mysql_error();
       exit;
    }
    
    if (mysql_num_rows($result1) == 0) {
       
    echo '<meta http-equiv=Refresh content=1;url="error.php">';
    
       
    }
    
    
    while ($row1 = mysql_fetch_assoc($result1)) {
    
       if ($order_total = "75.00") {
    session_start();
    echo "<meta http-equiv=Refresh content=1;url='listen2.php'>";   
    }
    
    if ($order_total = "5.00") {
    if ($date_purchased = (CURDATE)) {
    session_start();
    echo "<meta http-equiv=Refresh content=1;url='listen2.php'>";   
    } 
    }}
    mysql_free_result($result1);
    
    ?>
    

     

    If I enter the correct email address, it logs me in...no matter what is in $date_purchased. 

  7. Here's what I've come up with...and it doesn't work.  Parse error on line 33...expecting a "(" on this line

     

    if order_total = "75.00" {
    

     

    Can someone tell me if I'm even in the close to getting this right?  Thanks!

     

    <?php
    
    $conn1 = mysql_connect(localhost,xxx,xxx);
    
    if (!$conn1) {
       echo "Unable to connect to DB: " . mysql_error();
       exit;
    }
    
    if (!mysql_select_db("cart")) {
       echo "Unable to select mydbname: " . mysql_error();
       exit;
    }
    $sql1 = "SELECT customers_email_address, date_purchased, order_total FROM orders WHERE customers_email_address = '$_POST[myemail]'";
    
    $result1 = mysql_query($sql1);
    
    if (!$result1) {
       echo "Could not successfully run query ($sql1) from DB: " . mysql_error();
       exit;
    }
    
    if (mysql_num_rows($result1) == 0) {
       
    echo '<meta http-equiv=Refresh content=1;url="error.php">';
    
       
    }
    
    
    while ($row1 = mysql_fetch_assoc($result1)) {
    
       if order_total = "75.00" {
    session_start();
    echo "<meta http-equiv=Refresh content=1;url='listen2.php'>";   
    }
    
    if order_total = "5.00" {
    if date_purchased = CURDATE {
    session_start();
    echo "<meta http-equiv=Refresh content=1;url='listen2.php'>";   
    } 
    }}
    mysql_free_result($result1);
    
    ?>
    

  8. I need to write an authentication script.  Here are the details:

     

    I run a site that streams audio broadcasts of college sports games.  The listener needs to purchase the subscription.  I have  shopping cart setup to handle the sales.  The cart writes everything to a database.  The listener (customer) can purchase a single days "ticket" or the "season ticket" so that they can listen to EVERY game. 

     

    The authentication will allow the listener in to the "listen" page (that has an embedded player) only if they've purchased the subscription.  The cart doesn't have a "products" field so I can't check against the product ID to see if they have purchased the single day "ticket" or the "season" ticket.  Here's where I need some help.

     

    I need to check the database (for a single day ticket) so that if the email_address field of the DB exists and the date_purchased field equals the current date, it will authenticate the user.  If not, it ships them off to the shopping cart.  ONE NOTE...THE DATE PURCHASED FIELD IN THE DB IS CURDATE + TIME (2007-06-06 23:45:15).  I'd need to check against the date...not the time.

     

    Also, I need to check the DB (for a season ticket) so that if the email_address field of the DB exists and the order_total equals 75.00, it will authenticate the user.  If not, it ships them off to the shopping cart. 

     

    Can anyone point me in the right direction?  Thanks.

     

    Brian

  9. I'm getting an error:

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in daily.php on line 27

     

    Here's my code...

    <?PHP  
      
    //do your normal mysql setup and connection calls  
    $dbc = mysql_pconnect('xxx','xxx','xxx');  
    mysql_select_db('news',$dbc);  
    //now get stuff from a table  
    $sql = "SELECT date, story FROM stories WHERE ids = date";
    
    //now spit out the table and rows for the table  
    ?> 
    
      
    
    <strong> 
    News Archive 
    </strong><br> <br>
          <?php   
        	
    $rs = mysql_query($sql,$dbc);  
    $matches = 0; 
      
    while ($row = mysql_fetch_assoc($rs))  {
    $matches++; 
    echo "<font size='3'>".$row[date]."<br>";
    echo "<font size='3'>".$row[story]."<br><br>";  
    
      
    }  
    
    if (! $matches) { 
    echo ("<br>There are no news items for today"); 
    }  
    echo "</TABLE>";  
    ?> 
    

     

    The variable ids is being passed in the url like this:

     

    http://domain.com/localnews/daily.php?ids=2007-05-23

     

    No matter how I put the WHERE clause (order, quotes, no quotes) it doesn't return a record...even though I know there are records that match the date.  ANy ideas?

     

    Thanks.

     

    Brian

  10. I need some advice.  I'm looking to require payment AND authentication for a live audio stream for my site.  The system would be something like this:

     

    -User pays for the stream using Paypal.  The shopping cart would need to add the required data (username and password)to MY server's Mysql table.  They might pay for a single stream (one event) or they may purchase ALL streaming events.

     

    -User then gets redirected to the login page

     

    -User then enters the username and password and is able to listen to the stream (port 8000)

     

     

    I have a couple of questions, though.  Does anyone know of a shopping cart that plays with Paypal, that will also add the users info to my database, including which stream they purchased (single stream or every stream)?

     

    Also, can I just require the authentication on the playlist file (which calls the direct stream on port 8000), or do I need to require authentication for port 8000 server-wide?

     

    Thanks.

     

    Brian

  11. I need some advice on database design and layout.  I’m going to begin working on a project soon for a sports league.  I want to be able to enter and display game results and statistics for a variety of sports.  I would like to be able to layout the code in such a way that it works for EVERY sport.

     

    Here’s my problem.  Each sport has a different number of statistics that are kept.  Plus (soccer, baseball and hockey etc.) have stats specific to certain positions, where other sports (basketball volleyball etc.) use the same stats for all players.

     

    I’m thinking that I’ll need two tables…one for game results (score, opponent and such) and another for the individual player stats collected.  I also haven’t figured out if I want to keep the players names and such in a separate table or in the “stats” table.

     

    Since I’d like to keep the database the same structure for all sports, would a config file for each sport be in order?  That way I could tell the loops and such in the php code which table columns need to be manipulated based on what the sport is.

     

    For example:

    In baseball-

    (column 1 – games played) (column 2 – at bats) (column 3 – hits) (column 4 home runs)

     

    Then to determine the players batting average, I need to tell it to divide column 3 by column 2

     

    I am thinking that I’d need that info in the config file so that the code would work on multiple sports.

     

    So, two questions.  If you were designing something like this, what structure would you use, and would you use sport-specific config files for the math work…or would you go another route?

     

    Thanks.

     

    Brian

     

  12. Hi everyone, and thanks in advance for the help.

     

    I would like to have a way to remove all records in a database where the "date" column is prior to today (something like CURDATE() - INTERVAL 1 day)

     

    But, here's my problem.  I know that MySQL 5 has an "event" feature that will do this for me, but I want it run by a script.  I also don't want it run via cron.  I want an absolute php and mysql newbie to be able to get this working.

     

    I was thinking of adding a few lines on a regular web page that would delete the rows in the background when the public visits that page (could be the index page, could be another page)...but what if that page doesn't get visited each day?  Plus, that seems to be overkill, and not entirely safe.

     

    I could add the delete feature to the existing "write it to the db" script, so that every time something is written to the DB, it will purge the old records.  But this script doesn't get run very often in the summer.  How would I delete all the old records, regardless of how long ago they were entered?

     

    Is there another way to go about this that I'm not thinking of?  Any other suggestions?

     

    Thanks for your time!

     

    Brian

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