What's Wrong Here?

Discussion in 'PHP' started by IoWn3rU, Apr 11, 2010.

  1. #1
    <?php
    
    if ($_SERVER['REQUEST_METHOD'] == "POST") {
    
    $SQL = " UPDATE pick20 "; 
    $SQL = SET timescompleted=55;
    $SQL = SELECT * FROM pick20 WHERE timescompleted=timescompleted;
    $result = mysql_db_query($db,"$SQL",$cid);
    
    if (!$result) {
        echo("ERROR: " . mysql_error() . "\n$SQL\n"); }
    
    }
    
    mysql_close($cid);
    ?>
    Code (markup):
    It says this part is wrong: $SQL = SET timescompleted=55;
     
    IoWn3rU, Apr 11, 2010 IP
  2. nolag

    nolag Member

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #2
    should it not be

    $SQL = mysql_query("UPDATE pick20 SET timescompleted=55")
    or die (mysql_error());
    $SQL = mysql_query("SELECT * FROM pick20 WHERE timescompleted=timescompleted")
    or die(mysql_error());
     
    nolag, Apr 11, 2010 IP
  3. IoWn3rU

    IoWn3rU Peon

    Messages:
    420
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It says not database selected... :\
     
    IoWn3rU, Apr 11, 2010 IP
  4. Randombase

    Randombase Peon

    Messages:
    224
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Then you'll need:
    mysql_select_db('name_of_your_database');

    Goodluck!
     
    Randombase, Apr 11, 2010 IP
  5. nolag

    nolag Member

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #5
    mysql_connect("localhost", $loginname, $password) or die (mysql_error());
    mysql_select_db("$dbconnect") or die (mysql_error());

    where $loginname = your login name, $password = your password and $dbconnect = the database you want to connect to
     
    nolag, Apr 11, 2010 IP
  6. IoWn3rU

    IoWn3rU Peon

    Messages:
    420
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    What if I want to make timescompleted go up by 1 everytime a new entry is made with the same email address.

    So say we have this:

    kyle 1
    max 2
    john 1

    and if we get

    kyle 1
    max 2
    john 1
    john 1

    it changes both John's to 2?
     
    IoWn3rU, Apr 12, 2010 IP