AV Posted April 5, 2008 Share Posted April 5, 2008 Hey everybody, I made script to add match results, it has dynamically generated dropdown menu to select teams. Here's the code: add_match.php: <form method="post" action="add_match.php"> <img src="../templates/ico/flag_red.png" alt="Alpha"> <select name="tag_a"> <option>--------------</option> <?php $result = mysql_query("SELECT * FROM clans") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo '<option value="'.$row['tag'].'" name="tag_a">'.$row['tag'].'</option>'; } ?> </select> vs. <select name="tag_b"> <option>--------------</option> <?php $result = mysql_query("SELECT * FROM clans") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo '<option value="'.$row['tag'].'" name="tag_b">'.$row['tag'].'</option>'; } ?> </select> <img src="../templates/ico/flag_blue.png" alt="Bravo"> <br /><br /> <input type="text" name="score_a" class="login"> : <input type="text" name="score_b" class="login"> <br /><br /> <input type="submit" name="submit" value="Post" class="login_button"> </form> <?php if(isset($_POST['submit'])) { $tag_a = $_POST['tag_a']; $tag_b = $_POST['tag_b']; $score_a = $_POST['score_a']; $score_b = $_POST['score_b']; if(!empty($score_a) && !empty($score_b)) { $query = mysql_query("INSERT INTO matches SET id=NULL, date=CURDATE(), team_a='$team_a', team_b='$team_b', score_a='$score_a', score_b='$score_b'") or die(mysql_error()); if($score_a > $score_b){ // ALPHA WON mysql_query("INSERT INTO clans SET won='1' WHERE='$tag_a'") or die(mysql_error()); mysql_query("INSERT INTO clans SET lost='1' WHERE='$tag_b'") or die(mysql_error()); }elseif($score_a = $score_b){ // DRAW mysql_query("INSERT INTO clans SET draw='1' WHERE='$tag_a'") or die(mysql_error()); mysql_query("INSERT INTO clans SET draw='1' WHERE='$tag_b'") or die(mysql_error()); }elseif($score_a < $score_b){ // BRAVO WON mysql_query("INSERT INTO clans SET lost='1' WHERE='$tag_a'") or die(mysql_error()); mysql_query("INSERT INTO clans SET won='1' WHERE='$tag_b'") or die(mysql_error()); } echo 'Done Successfully!'; }else{ echo 'FILL OUT ALL FIELDS, d00d!'; } } // $tag_a = team1 tag // $tag_b = team2 tag // $score_a = team1 score // etc. When executing this I get error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE='team1'' at line 1 Any ideas what's wrong? It doesn't put $tag_a and $tag_b datas into the table Link to comment https://forums.phpfreaks.com/topic/99669-doesnt-put-few-datas-in-table/ Share on other sites More sharing options...
paul2463 Posted April 5, 2008 Share Posted April 5, 2008 WHERE <b><i> WHAT</i></b> = team1??? Link to comment https://forums.phpfreaks.com/topic/99669-doesnt-put-few-datas-in-table/#findComment-509887 Share on other sites More sharing options...
AV Posted April 5, 2008 Author Share Posted April 5, 2008 Thanks mate it seems I'm really tired if I make such a crappy mistakes Link to comment https://forums.phpfreaks.com/topic/99669-doesnt-put-few-datas-in-table/#findComment-509917 Share on other sites More sharing options...
Barand Posted April 5, 2008 Share Posted April 5, 2008 and should these be $tag_a and $tag_b $query = mysql_query("INSERT INTO matches SET id=NULL, date=CURDATE(), team_a='$team_a', team_b='$team_b', score_a='$score_a', score_b='$score_b'") Link to comment https://forums.phpfreaks.com/topic/99669-doesnt-put-few-datas-in-table/#findComment-509953 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.