Jump to content

colickyboy

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

colickyboy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. unfortunately, i think i've stumped everyone. i created a form for one team instead of two teams to see if maybe too much data was causing the problem. indeed, a form for one team worked...except when a team's roster hits 19 people...then it stopped working again. so it does appear to be a limitation of how much data can be passed. does anyone know anything about this? there has to be a way around this b/c i'm sure others are submitting lots more data at a time than i am...
  2. Good catch on the spaces...I've changed that. However, it didn't fix the problem. It does seem like a lot of data being passed, but I've used this script last year without problems. That's part of what makes this maddening!
  3. it exceeds the allowed message length here, so i attached it as a txt file. sorry, it's hard to read that way... [attachment deleted by admin]
  4. here is the html source for 6 columns (this is for queried player #: <td><input type="text" name="pos-8" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="ab-8" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="r-8" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="b1-8" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="b2-8" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="b3-8" align="top" maxlength="2" size="2" /></td> </tr>
  5. OK, I did that but it still didn't work. Once again, when I hard coded 5 cols that way (without the []), it worked...but when I hard coded the 6th col, it failed!
  6. hi frost110, i'm actually not using the $i to define the index of the array. i'm using it to assign a number for each queried player so i can later post their stats without confusing which stats below to whom. here's the html source of the form that's generated... it may better explain what the generated form looks like: <tr> <td colspan="14"> <input type="hidden" name="id[1]" value="197" /> <input type="hidden" name="name[1]" value="Brian White" /> <input type="hidden" name="team[1]" value="Rock Salt" /> <input type="hidden" name="gameid[1]" value="40" /> </td> </tr> <tr> <td>Brian White</td> <td><select name="battingorder[1]"> <option value='' selected></option><br /> <option value = '1'>1</option><br /> <option value = '2'>2</option><br /> ... <option value = '17'>17</option><br /> </select> </td> <td><input type="text" name="pos[1]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="AB[1]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="R[1]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="B1[1]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="B2[1]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="B3[1]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="HR[1]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="RBI[1]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="SF[1]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="BB[1]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="K[1]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="E[1]" align="top" maxlength="2" size="2" /></td> </tr> <tr> <td colspan="14"> <input type="hidden" name="id[2]" value="193" /> <input type="hidden" name="name[2]" value="Eric Liu" /> <input type="hidden" name="team[2]" value="Rock Salt" /> <input type="hidden" name="gameid[2]" value="40" /> </td> </tr> <tr> <td>Eric Liu</td> <td><select name="battingorder[2]"> <option value='' selected></option><br /> <option value = '1'>1</option><br /> ... <option value = '17'>17</option><br /> </select> </td> <td><input type="text" name="pos[2]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="AB[2]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="R[2]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="B1[2]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="B2[2]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="B3[2]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="HR[2]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="RBI[2]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="SF[2]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="BB[2]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="K[2]" align="top" maxlength="2" size="2" /></td> <td><input type="text" name="E[2]" align="top" maxlength="2" size="2" /></td> </tr> When submitted, the code processes each player, keeping track of all the stats for each player by the index (each player is assigned an index number). i tried removing the $i as you suggested just for kicks and not surprisingly, that didn't work. for what it's worth, i did the post_test.php that you suggested, and i did get output.
  7. if i replace the foreach loop construct and hardcode 5 cols, it works...clicking submit brings a page that echos "hello" echo '<td><input type="text" name="pos[' . $i . ']" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="ab[' . $i . ']" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="r[' . $i . ']" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="b1[' . $i . ']" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="b2[' . $i . ']" align="top" maxlength="2" size="2" /></td>'; but if i add a 6th col, it fails...clicking submit gives me a blank page again echo '<td><input type="text" name="pos[' . $i . ']" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="ab[' . $i . ']" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="r[' . $i . ']" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="b1[' . $i . ']" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="b2[' . $i . ']" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="b3[' . $i . ']" align="top" maxlength="2" size="2" /></td>'; so bizarre...any idea why this is happening?
  8. Are you saying the first item in the array that is passed through foreach is causing the problem? That seems odd. If that really is the case, how would I get around that?
  9. There are always 14 total <td>...12 from the array used in foreach, 1 for the batting order position, and 1 for the player's name. I adjusted the <input> tags to be inside <td> as follows: <div id='header'>Enter player results for <?php echo fdate($gamedate)?></div><br /><br /> <?php $result = mysql_query("SELECT id, name, team FROM players WHERE team in ('$visitor','$home') AND year='$year' ORDER BY team, name"); $count = mysql_num_rows($result); $teamck = ""; $i = 1; echo "<form method='post' action=''>"; echo "<table>"; echo "<tr><td colspan='14'><input type='hidden' name='count' value='" . $count . "'>"; echo "<input type='hidden' name='date' value='" . $gamedate . "'></td></tr>"; while ($myrow = mysql_fetch_assoc($result)) { $id = $myrow["id"]; $team = $myrow["team"]; if ($teamck != $team) { echo "<tr><td colspan='14' align='center'>$team</td></tr> <tr> <td>Name</td> <td>Order</td> <td>POS</td> <td>AB</td> <td>R</td> <td>1B</td> <td>2B</td> <td>3B</td> <td>HR</td> <td>RBI</td> <td>SF</td> <td>BB</td> <td>K</td> <td>E</td> </tr>"; } if ($count > 0) { $name = $myrow["name"]; echo '<tr><td colspan="14"><input type="hidden" name="id[' . $i . ']" value="' . $id . '" />'; echo '<input type="hidden" name="name[' . $i . ']" value="' . $name . '" />'; echo '<input type="hidden" name="team[' . $i . ']" value="' . $team . '" />'; echo '<input type="hidden" name="gameid[' . $i . ']" value="' . $gameid . '" /></td></tr>'; echo "<tr><td>$name</td>"; echo '<td><select name="battingorder[' . $i .']">'; echo "<option value='' selected></option><br />"; for ($n = 1; $n <= 17; $n++){ echo "<option value = '$n'>$n</option><br />"; } echo "</select></td>"; foreach ($cols as $col) { echo '<td><input type="text" name="' . $col . '[' . $i .']" align="top" maxlength="2" size="2" /></td>'; } echo "</tr>"; $i++; $teamck = $team; } } echo "<tr><td colspan='14'><input type='submit' name='submit' value='Submit'></td></tr><br /><br />"; echo "</table></form>"; Still doesn't work.
  10. thanks, thefortrees...but that's not necessary b/c the form works if i take out the little foreach code snippet. and i have another form page also with no form action (but no foreach code) that also works. just to cover all the bases, i tried declaring a specific form action anyway and it didn't work...still getting a blank page. apparently, this foreach line is causing the hiccup. i'm using php 4.4.6. i'm stumped what's wrong with the foreach line. mr_zhang, thanks for the suggestions. yes, i did define the $cols. and to eliminate the posting variables as a possible culprit, i replaced all the real actions upon submit and just told it to echo "hello" upon submit. the form displays properly with the foreach code...and looking at the source code it generates, it seems ok. but for some reason, clicking submit brings a blank page with the foreach code in, and "hello" echoed properly with the foreach code out!
  11. I'm really close I think...I've narrowed down the culprit to the following: foreach ($cols as $col) { echo '<td><input type="text" name="' . $col . '[' . $i .']" align="top" maxlength="2" size="2" /></td>'; } If I take out this snippet, the form works and I don't get a blank page after submit. This snippet is part of this block of code: <div id='header'>Enter player results for <?php echo fdate($gamedate)?></div><br /><br /> <?php $result = mysql_query("SELECT id, name, team FROM players WHERE team in ('$visitor','$home') AND year='$year' ORDER BY team, name"); $count = mysql_num_rows($result); $teamck = ""; $i = 1; echo "<form method='post' action=''>"; echo "<table>"; echo "<input type='hidden' name='count' value='" . $count . "'>"; echo "<input type='hidden' name='date' value='" . $gamedate . "'>"; while ($myrow = mysql_fetch_assoc($result)) { $id = $myrow["id"]; $team = $myrow["team"]; if ($teamck != $team) { echo "<tr><td colspan='13' align='center'>$team</td></tr> <tr> <td>Name</td> <td>Order</td> <td>POS</td> <td>AB</td> <td>R</td> <td>1B</td> <td>2B</td> <td>3B</td> <td>HR</td> <td>RBI</td> <td>SF</td> <td>BB</td> <td>K</td> <td>E</td> </tr>"; } if ($count > 0) { $name = $myrow["name"]; echo '<input type="hidden" name="id[' . $i . ']" value="' . $id . '" />'; echo '<input type="hidden" name="name[' . $i . ']" value="' . $name . '" />'; echo '<input type="hidden" name="team[' . $i . ']" value="' . $team . '" />'; echo '<input type="hidden" name="gameid[' . $i . ']" value="' . $gameid . '" />'; echo "<tr><td>$name</td>"; echo '<td><select name="battingorder[' . $i .']">'; echo "<option value='' selected></option><br />"; for ($n = 1; $n <= 17; $n++){ echo "<option value = '$n'>$n</option><br />"; } echo "</select></td>"; foreach ($cols as $col) { echo '<td><input type="text" name="' . $col . '[' . $i .']" align="top" maxlength="2" size="2" /></td>'; } echo "</tr>"; $i++; $teamck = $team; } } echo "<tr><td colspan='14'><input type='submit' name='submit' value='Submit'></td></tr><br /><br />"; echo "</table></form>"; However, I don't see anything wrong with the foreach syntax...or is there?
  12. Hi btherl, I get: _REQUEST contains: array(0) { } _POST contains: array(0) { } _GET contains: array(0) { }
  13. It says: Notice: Undefined index: visitor in /gamestats.php on line 19 Notice: Undefined index: home in /gamestats.php on line 20 Notice: Undefined index: gameid in /gamestats.php on line 21 Notice: Undefined index: gamedate in /gamestats.php on line 22 which relate to: $visitor = $_REQUEST['visitor']; $home = $_REQUEST['home']; $gameid = $_REQUEST['gameid']; $gamedate = $_REQUEST['gamedate']; I tried fiddling with these but it got worse. Advice?
  14. I have a page that takes input for softball stats and then updates two mysql databases. This page worked last year but this year generates a blank page after clicking Submit and no databases are updated. Here is the code, all on one page (gamestats.php): $year = 2007; $visitor = $_REQUEST['visitor']; $home = $_REQUEST['home']; $gameid = $_REQUEST['gameid']; $gamedate = $_REQUEST['gamedate']; $PHP_SELF = $_SERVER['PHP_SELF']; function fdate($date) { $mdy=explode("-", $date); $Yr=$mdy[0]; $Mo=$mdy[1]; $Dy=$mdy[2]; $newtime=date("l, M j, Y", mktime(0,0,0,$Mo,$Dy,$Yr)); return $newtime; } $cols = array('pos','AB','R','B1','B2','B3','HR','RBI','SF','BB','K','E'); if (isset($_POST['submit'])) { // update players' game stats $count = $_POST["count"]; $id = $_POST["id"]; //$name = $_POST["name"]; for ($i = 1; $i <= $count; $i++) { echo 'id[' . $i . '] = ' . $_POST['id'][$i] . "<br>"; echo "date = " . $_POST['date'] . "<br>"; echo 'name[' . $i . '] = ' . $_POST['name'][$i] . "<br>"; echo 'team[' . $i . '] = ' . $_POST['team'][$i] . "<br>"; echo 'opp[' . $i . '] = ' . $_POST['opp'][$i] . "<br>"; echo 'battingorder[' . $i . '] = ' . $_POST['battingorder'][$i] . "<br>"; echo 'pos[' . $i . '] = ' . $_POST['pos'][$i] . "<br>"; echo 'AB[' . $i . '] = ' . $_POST['AB'][$i] . "<br>"; echo 'R[' . $i . '] = ' . $_POST['R'][$i] . "<br>"; echo 'B1[' . $i . '] = ' . $_POST['B1'][$i] . "<br>"; echo 'B2[' . $i . '] = ' . $_POST['B2'][$i] . "<br>"; echo 'B3[' . $i . '] = ' . $_POST['B3'][$i] . "<br>"; echo 'HR[' . $i . '] = ' . $_POST['HR'][$i] . "<br>"; echo 'RBI[' . $i . '] = ' . $_POST['RBI'][$i] . "<br>"; echo 'SF[' . $i . '] = ' . $_POST['SF'][$i] . "<br>"; echo 'BB[' . $i . '] = ' . $_POST['BB'][$i] . "<br>"; echo 'K[' . $i . '] = ' . $_POST['K'][$i] . "<br>"; echo 'E[' . $i . '] = ' . $_POST['E'][$i] . "<br>"; $qtmp = array(); $qtmp2 = array(); foreach ($_POST as $k => $dmy) switch($k) { // case 'G': // $qtmp[] = 'G = G + 1'; // break; case 'submit': case 'count': case 'id': case 'name': case 'team': case 'gameid': case 'date': case 'pos': case 'battingorder': // // do nothing // break; default: // all other fields if ($_POST[$k][$i] != '') { $qtmp[] = $_POST[$k][$i]; $qtmp2[] = $k . '=' . $k . '+' . $_POST[$k][$i]; } break; } if (!empty($qtmp)) { $q = "INSERT INTO gamestats (name, date, team, gameid, battingorder, pos, AB, R, B1, B2, B3, HR, RBI, SF, BB, K, E) VALUES ('" . $_POST['name'][$i] . "', '" . $_POST['date'] . "', '" . $_POST['team'][$i] . "', '" . $_POST['gameid'][$i] . "', '" . $_POST['battingorder'][$i] . "', '" . $_POST['pos'][$i] . "', " . implode(', ',$qtmp) . ")"; $result = mysql_query($q) or die("Problem updating DB, query: $q<br>" . mysql_error()); } if (!empty($qtmp2)) { $q = "UPDATE players SET G=G+1, " . implode(', ',$qtmp2) . " where id=" . $_POST['id'][$i]; $result = mysql_query($q) or die("Problem updating DB, query: $q<br>" . mysql_error()); } } echo "Game results entered."; } else { if (!$gamedate) { echo "<div id='header'>MCSN Softball Update Central</div><br><br>"; $result = mysql_query("SELECT id, date, visitor, home FROM gameresults WHERE year='$year' AND date <= curdate() ORDER BY date"); if ($myrow = mysql_fetch_array($result)) { printf("<ul>"); do { $gameid = $myrow["id"]; $date = $myrow["date"]; $visitor = $myrow["visitor"]; $home = $myrow["home"]; printf("<li type='square'><a href=\"%s?gamedate=%s&visitor=%s&home=%s&gameid=%s\">%s: %s at %s</a><br> \n", $PHP_SELF, $date, $visitor, $home, $gameid, fdate($date), $visitor, $home); echo "<br><br>"; } while ($myrow = mysql_fetch_array($result)); printf("</ul></div>"); } } if ($gamedate) { ?> <form method="post" action=""> <div id='header'>Enter player results for <?php echo fdate($gamedate)?></div><br><br> <?php $result = mysql_query("SELECT id, name, team FROM players WHERE team in ('$visitor','$home') AND year='$year' ORDER BY team, name"); $count = mysql_num_rows($result); echo "<table>"; $teamck = ""; $i = 1; while ($myrow = mysql_fetch_assoc($result)) { $id = $myrow["id"]; $team = $myrow["team"]; if ($teamck != $team) { echo "<tr><td colspan='13' align='center'>$team</td></tr> <tr> <td>Name</td> <td>Order</td> <td>POS</td> <td>AB</td> <td>R</td> <td>1B</td> <td>2B</td> <td>3B</td> <td>HR</td> <td>RBI</td> <td>SF</td> <td>BB</td> <td>K</td> <td>E</td> </tr>"; } if ($count > 0) { $name = $myrow["name"]; echo '<input type="hidden" name="id[' . $i . ']" value="' . $id . '">'; echo '<input type="hidden" name="name[' . $i . ']" value="' . $name . '">'; echo '<input type="hidden" name="team[' . $i . ']" value="' . $team . '">'; echo '<input type="hidden" name="gameid[' . $i . ']" value="' . $gameid . '">'; echo "<tr><td>$name</td>"; //echo "<td><input type='text' name='" . $pos . "[" . $i . "]' align='top' maxlength='2' size='2'></td>"; echo '<td><select name="battingorder[' . $i .']">'; echo "<option value='' selected></option><br>"; for ($n = 1; $n <= 17; $n++){ echo "<option value = '$n'>$n</option><br>"; } echo "</select></td>"; foreach ($cols as $col) echo '<td><input type="text" name="' . $col . '[' . $i .']" align="top" maxlength="2" size="2"></td>'; echo "</tr>"; $i++; $teamck = $team; } } echo "</table>"; echo '<input type="hidden" name="count" value="' . $count . '">'; echo '<input type="hidden" name="date" value="' . $gamedate . '">'; echo '<input type="submit" name="submit" value="Submit"><br><br>'; echo '</form>'; } } ?> This year I'm on PHP 4.4.6. Don't remember what I was on last year. I asked my ISP if it was an environment issue with the change to PHP 4.4.6 and they said it's a coding issue. What's wrong with the code that makes it not submit?
×
×
  • 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.