Jump to content

djlotus

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

djlotus's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Unfortunately, I have tried and failed miserably at understanding most MySQL query structures. Fenways answer makes sense, but I have no idea how to put it into code. I tried to grasp it. but to no avail.
  2. [!--quoteo(post=358290:date=Mar 25 2006, 12:49 PM:name=annihilate)--][div class=\'quotetop\']QUOTE(annihilate @ Mar 25 2006, 12:49 PM) [snapback]358290[/snapback][/div][div class=\'quotemain\'][!--quotec--] Refreshing the page straight after submission is resubmitting the data, so that's probably why it appears again. To prevent this, just query the database to see if the data being submitted is already there. If the username must be unique, then just query the username field. Limit the query to 1 row. If it finds 1 row, then don't insert, else no rows are found so do the insert. [code]SELECT name FROM members WHERE name = $new_username LIMIT 1;[/code] [/quote] Where would you suggest inserting that string into the code?
  3. Let me preface this question by saying I am a complete novice with mysql. Below is a description of the problem. Any help would be greatly appreciated. I have also included the part of the script that I believe pertains to the adition of the new player into the DB. This is only a par to fthe page in whole. I am running a gaming ladder script. When I enter a new player to a roster, It shows the new member only once on the roster. Upon refreshing the page, It shows the new entry twice. I checked the Db and found that it is submitting duplicate entries every time a new player is added to the DB. [code]if (isset($add_new_player)){ $query_count = "SELECT COUNT(*) FROM members WHERE team_id='$team_id'" or die("Error in query_count");   $result_count = mysql_db_query($db, $query_count, $dblink) or die("Error in result_count"); $max_count = mysql_result($result_count,0); $query_size = "SELECT * FROM ladders WHERE ladder_id='$ladder_id'" or die("Error in query_size"); $result_size = mysql_db_query($db, $query_size, $dblink) or die("Error in result_size"); while($links = mysql_fetch_array($result_size)) { $max_size = $links["max_size"]; } if ($max_count >= $max_size) { Echo " <TABLE BORDER=0 BGCOLOR='$table_bg_color' CELLPADDING='2' CELLSPACING='$fancy_table_border' WIDTH='$manage_table_width'> <TR BGCOLOR='$tr_bg_color'> <TD><CENTER><font class=text>Only $max_size player(s) are allowed per team</CENTER></TD> </TR> </TABLE>      <TABLE BORDER=0 CELLPADDING='0' CELLSPACING='$fancy_table_border' WIDTH='$manage_table_width'> <TR> <TD HEIGHT=2></TD> </TR> </TABLE>"; return; } $query_new_player = "INSERT INTO members (ladder_id, team_id, name, last_modified, joined, modified, member_rank, accepted) values('$ladder_id','$team_id','$new_username','Never','$modified_date','Never','Member','yes')"; $result_new_player  = @mysql_db_query($db, $query_new_player, $dblink) or die("Error in insert_new_player "); Echo " <TABLE BORDER=0 BGCOLOR='$table_bg_color' CELLPADDING='2' CELLSPACING='$fancy_table_border' WIDTH='$manage_table_width'> <TR BGCOLOR='$tr_bg_color'> <TD><CENTER><font class=text>$new_username was added on $modified_date</CENTER></TD> </TR> </TABLE> <TABLE BORDER=0 CELLPADDING='0' CELLSPACING='$fancy_table_border' WIDTH='$manage_table_width'> <TR> <TD HEIGHT=2></TD> </TR> </TABLE>"; } [/code]
×
×
  • 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.