Jump to content

Tino

Member
  • Posts

    5
  • Joined

  • Last visited

Posts posted by Tino

  1. You can make that code a lot easier. Also, it's best practice to store your queries in variables.

     

    $con = mysql_connect("localhost","root","");
    
    if (!$con){
       die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db("stats", $con) or die(mysql_error());
    
    if ($score_compare[1] == $score_compare[2]) {
       $query = "INSERT INTO `standings` (draw,team1,team2) VALUES ('".$draw."','".$team."','".$team2."')";
       $result = mysql_query($query) or die(mysql_error());
    } elseif ($score_compare[1] > $score_compare[2]) {
       $query = "INSERT INTO `standings` (wins,team1,loss,team2) VALUES ('".$wins."','".$team."','".$loss."','".$team2."')";/
       $result = mysql_query($query) or die(mysql_error());
    } else {
       if ($score_compare[1] < $score_compare[2]) {
           $query = "INSERT INTO `standings` (loss,team1,wins,team2) VALUES ('".$loss."','".$team."','".$wins."','".$team2."')";
           $result = mysql_query($query) or die(mysql_error());
       }
    mysql_close($con);
    }
    

  2. If I'm correct, you can't have whitespace like that in HTML forms, which means you would have to use name="loss" instead of name = "loss".

     

    Aside of that, I'd put everything you have after the if condition inside the code block of the if statement, rather than just the connection.

×
×
  • Create New...