Jump to content

mtnmchgrl

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mtnmchgrl's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I just sent it in a message to you. Thank you! Anyone else?? The problem jumped out at me once I tried to run it. You cannot do an INSERT...WHERE. That would imply that you already have a row that meets the WHERE criteria in which case you do an UPDATE. It would be UPDATE stats set atBats='$abats', hits = '$hits', walks='$walks', RBI= '$RBI', strkOuts='$strkOuts', singles='$singles', doubles='$doubles', triples='$triples', homeRuns='$homeruns', runsScrd='$runsScrd', fieldersCh='$fieldersCh' where FK_playerID='$FK_playerID' and FK_tourneyID='$FK_tourneyID'; I have just assumed that those are the variable names and if not, you get the drfit. [attachment deleted by admin]
  2. I just sent it in a message to you. Thank you! The problem jumped out at me once I tried to run it. You cannot do an INSERT...WHERE. That would imply that you already have a row that meets the WHERE criteria in which case you do an UPDATE. It would be UPDATE stats set atBats='$abats', hits = '$hits', walks='$walks', RBI= '$RBI', strkOuts='$strkOuts', singles='$singles', doubles='$doubles', triples='$triples', homeRuns='$homeruns', runsScrd='$runsScrd', fieldersCh='$fieldersCh' where FK_playerID='$FK_playerID' and FK_tourneyID='$FK_tourneyID'; I have just assumed that those are the variable names and if not, you get the drfit. That makes sense b/c the first 2 fields already exist!!! However, I just did this and I'm still getting an error. Plus the query to actually insert the records doesn't contain a WHERE. The select statement below that (that shows all the stats) is the one that has the where and it is working just fine. Its the first query that is not working.....the one to add stuff to the db. Man i thought this was really going to fix it too. Grrrr....
  3. lol, well I guess it's a personally prefernce, but standard check boxes look kind of tacky. I do graphic design, so designing a button is convenient. All it is basically, you click it, and the button turns white, and then you click it again, and it turns black. After that, I want to get the value of the button, where it is white or black (checked or not checked) (clicked or not clicked, lol) . Hmm....I did something kind of like this using CSS. My nav bar....the link buttons when not clicked are one color and when clicked, they display an image.....is that kind of what you mean ?
  4. Yes, I use xampp/apache to run this site...just local host. Can I use either of those programs with that?? I have access to PHPMyAdmin but I hate using it...I ended up doing all my tables from scratch in command line. Sigh.....
  5. I tested that. No problems with the inputted data, so it has to be my query.....am I referencing the foreign keys right? Remember, the 2 foreign keys referenced are linked to 2 different tables.......to me it would make sense to right sql query like: mysql> insert into stats (FK_tourneyID, FK_playerID, atBats, hits, walks, RBI, strkOuts, singles, do ubles, triples, homeRuns, runsScrd, fieldersCh) VALUES (1, 13, 10, 3, 1, 0, 0, 1, 1, 1, 0, 0, 0) w here FK_playerID=13 and FK_tourneyID=1; But this does not seem to work. I also took off the FK_ and it didn't work either. Any help would be appreciated.... [attachment deleted by admin]
  6. 1. All the entries are numbers (whole) with the exception of the playerFN/LN which is linked to playerID (which is a #) and the tournament name which is linked by tourneyID. not sure if those two matter as they are existing fields in db? 2. Not sure if I understood your thing about the quotes, but I took off the quotes on the column names (the first set of parenthesis in the INSERT statement (before values). 3. There aren't any strings being entered so I don't think there is a need for the mysql_real_escape_string() at all 4. I changed my query to just show all 10 players and ALL their stats (100 records total). For some reason my atBats column isn't showing up although i don't see anything weird..... 5. No longer getting parser/syntax error but we are back to this error: The following errors occured: * Doubles are required. * Triples are required. * Home Runs are required. * Runs Scored are required. * Fielders Choice is required. So close....anyone else??? Modifed attached. [attachment deleted by admin]
  7. Ok, caught that and a few other little things. Form is showing up w/out the parse/syntax error page but its still not submitting properly. Nothing gets submitted and I get these errors: The following errors occured: * Home Runs are required. * Runs Scored are required. * Fielders Choice is required. Think there is something wonky w/ my query too b/c its not filling up right at the bottom. It should show the last entered record..... Getting closer......... What syntax editor do you use? I use Crimson Editor and Dreamweaver. DW sucks for this kind of stuff. What do you recommend? Re attaching new .php [attachment deleted by admin]
  8. Hello again, I just realized this didn't make sense. On this form, I am adding statistics for each game and player. The name of the tournament and the player is already in the db (b/c you can't add stats on games that don't exist). So all the person sees is 2 drop downs and then the stat input boxes. The first drop down should be the name of the tournament. The second drop down is the players first and last names (which is a concatenation of the playerFN, playerLN columns). While it looks like alot I am certain the input fields are set up correctly considering they are the same from the other form. I am unsure about the <option select> drop down fields and how i have that set up. I did have the drop downs working before but the adding of new records would not work. That was before i reworked the data from that previous thread. This is the last one I am working on so if anyone could help again I would be VERY appreciative....... The drop downs are toward the bottom of the page w/ all the input field code. I tried to run this and it gave me this error: Parse error: syntax error, unexpected T_STRING, expecting ']' in L:\addStats.php on line 183 Line 183 is this: <?php include_once('includes/admin_nav.inc.php'); ?> So that makes no sense.... <?php // START SESSION require_once('includes/session.inc.php'); // CONNECT TO DATABASE require_once('includes/connect.inc.php'); // PROCESS FORM ON SUBMIT $response = ''; if (isset($_POST['submit'])) { //Create array var to capture errors $errors = array(); //VALIDATE THE SUBMITTED DATA $tournID = trim($_POST['tourneyID']); $playID = trim($_POST['playerID']); $AB = trim($_POST['atBats']); $H = trim($_POST['hits']); $W = trim($_POST['walks']); $RBI = trim($_POST['RBI']); $SO = trim($_POST['strkOuts']); $S = trim($_POST['singles']); $D = trim($_POST['doubles']); $T = trim($_POST['triples']); $hR = trim($_POST['homeRuns']); $rS = trim($_POST['runsScrd']); $fCh = trim($_POST['fieldersCh']); //IF STATEMENTS TO CHECK FOR EMPTY FIELDS if(empty($tournID)) { $errors[] = "Tournament ID is required."; } if(empty($playID)) { $errors[] = "Player ID is required."; } if(empty($AB)) { $errors[] = "At Bats are required."; } if(empty($H)) { $errors[] = "Hits are required."; } if(empty($W)) { $errors[] = "Walks are required."; } if(empty($RBI)) { $errors[] = "RBI is required."; } if(empty($SO)) { $errors[] = "Strike Outs are required."; } if(empty($S)) { $errors[] = "Singles are required."; } if(empty($D)) { $errors[] = "Doubles are required."; } if(empty($T)) { $errors[] = "Triples are required."; } if(empty($hR)) { $errors[] = "Home Runs are required."; } if(empty($rS)) { $errors[] = "Runs Scored are required."; } if(empty($fCh)) { $errors[] = "Fielders Choice is required."; } //IF THE THE NUMBER OF ERRORS IS GREATER THAN ZERO, THEN THE MESSAGES WILL DISPLAY IN THIS FASHION... if(count($errors)>0) { //There were validation errors, prepare error message $response = "<span style=\"color:red;\">"; $response .= "The following errors occured:\n"; $response .= "<ul>"; $response .= '<li>' . implode('</li><li>', $errors) . '</li>'; $response .= "</ul>\n"; $response .= "</span>\n"; } else { //IF NO VALIDATION ERRORS, SAVE INPUT DATA TO DATABASE $tournID = mysql_real_escape_string($tournID); $playID = mysql_real_escape_string($playID); $AB = mysql_real_escape_string($AB); $H = mysql_real_escape_string($H); $W = mysql_real_escape_string($W); $RBI = mysql_real_escape_string($RBI); $SO = mysql_real_escape_string($SO); $S = mysql_real_escape_string($S); $D = mysql_real_escape_string($D); $T = mysql_real_escape_string($T); $hR = mysql_real_escape_string($hR); $rS = mysql_real_escape_string($rS); $fCh = mysql_real_escape_string($fCh); // QUERY TO RETRIEVE ENTRY RESULTS $query="INSERT INTO `stats` (`tourneyID`, `playerID`, `atbats`, `hits`, `walks`, `RBI`, `strkOuts`, `singles`, `doubles`, `triples`, `homeRuns`, `runsScrd`, `fieldersCh`) VALUES ('{$tournID}', '{$playID}', '{$AB}', '{$H}', '{$W}', '{$RBI}', '{$SO}', '{$S}', '{$T}', '{$hR}', '{$rS}', '{$fCh}')"; $result = mysql_query($query); if (!$result) { $response = "No record was added. Please try again."; $response .= "<br />\n$query<br />".mysql_error(); } else { $response = "The record has been added."; } } } //GET CURRENT RECORDS TO DISPLAY - THIS WILL SHOW ME THE LAST ROW I ENTERED $query = "SELECT playerID, playerFN, playerLN, tourneyID, tourneyName, atbats, hits, walks, RBI, strkOuts, singles, doubles, triples, homeRuns, runsScrd, fieldersCh FROM `player`, `tournaments`, `stats` WHERE player.playerID=stats.FK_playerID AND tournaments.tourneyID=stats.FK_tourneyID ORDER BY playerID DESC LIMIT 1"; $result = mysql_query($query); //VALIDATE THERE WERE RECORDS if(mysql_num_rows($result) == 0) { $records = "Sorry, no records were found!"; } else { // START OF TABLE, HEADERS, ETC $records = "<table border=\"1\">\n"; $records .= "<tr><th>TourneyID</th><th>PlayerID</th><th>AB</th><th>H</th><th>W</th><th>RBI</th><th>SO</th><th>S</th><th>D</th><th>T</th><th>HR</th><th>RS</th><th>FC</th></tr>\n"; //LOOP THE DATABASE TO DISPLAY THE RECORDS while ($myrow = mysql_fetch_array($result)) { //PRINT RESULTS $records .= "<tr>"; $records .= "<td>{$myrow['tourneyID']}</td>"; $records .= "<td>{$myrow['playerID']}</td>"; $records .= "<td>{$myrow['atBats']}</td>"; $records .= "<td>{$myrow['hits']}</td>"; $records .= "<td>{$myrow['walks']}</td>"; $records .= "<td>{$myrow['RBI']}</td>"; $records .= "<td>{$myrow['strkOuts']}</td>"; $records .= "<td>{$myrow['singles']}</td>"; $records .= "<td>{$myrow['doubles']}</td>"; $records .= "<td>{$myrow['triples']}</td>"; $records .= "<td>{$myrow['homeRuns']}</td>"; $records .= "<td>{$myrow['runsScrd']}</td>"; $records .= "<td>{$myrow['fieldersCh]}</td>"; $records .= "</tr>\n"; } $records .= "</table>\n"; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <title>Admin MySQL Database</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="css/admin.css" rel="stylesheet" type="text/css"> </head> <body> <div id="navigation"> <?php include_once('includes/admin_nav.inc.php'); ?> </div> <!--END NAVIGATION DIV--> <div id="content"> <h1>Add Statistics</h1> <br /> <div><?php echo $response; ?></div> <!--HTML FORM FOR ENTRY OF THE STATS!--> <form method="post" action=""><!--addStats.php--> <p>Select Tournament: <select name="tourneyID"> <?php // CONNECT TO DATABASE require_once('includes/connect.inc.php'); //THIS QUERY GETS tourneyID, tourneyName and gameDate from tournaments table. $result = mysql_query("SELECT * FROM tournaments"); while ($myrow = mysql_fetch_array($result)) { //THIS IS MY DROP DOWN WHERE THE PERSON SHOULD SELECT THE NAME OF THE EXISTING TOURNAMENT. echo'<option value="'.$myrow['tourneyID'].'">'.$myrow['tourneyName'].'</option>'; } ?> </select> </p> <p>Select Player: <select name="playerID"> <?php //THIS QUERY GETS FIRST THREE FIELDS OF PLAYER TABLE $result = mysql_query("SELECT playerID, playerFN, playerLN FROM player"); while ($myrow = mysql_fetch_array($result)) { //THIS IS MY DROP DOWN SHOWING THE CONCATENATED PLAYERS FIRST AND LAST NAME echo'<option value="'.$myrow['playerID'].'">'.$myrow['playerFN'].' '.$myrow['playerLN'].'</option>'; } ?> </select></p> <!--HERE IS WHERE THE INPUT FIELDS FOR EACH STATISTIC WILL GO - DATA THAT IS TO BE ENTERED AND IS NOT ALREADY IN db--> <table border=1 RULES=NONE FRAME=BOX> <tr> <td>At Bats:</td> <td><input type="text" name="atBats" size="20" maxlength="20"></td> </tr> <tr> <td>Hits:</td> <td><input type="text" name="hits" size="20" maxlength="20"></td> </tr> <tr> <td>Walks:</td> <td><input type="text" name="walks" size="20" maxlength="20"></td> </tr> <tr> <td>RBI:</td> <td><input type="text" name="RBI" size="20" maxlength="20"></td> </tr> <tr> <td>Strike Outs:</td> <td><input type="text" name="strkOuts" size="20" maxlength="20"></td> </tr> <tr> <td>Singles:</td> <td><input type="text" name="singles" size="20" maxlength="20"></td> </tr> <tr> <td>Doubles:</td> <td><input type="text" name="doubles" size="20" maxlength="20"></td> </tr> <tr> <td>Triples:</td> <td><input type="text" name="triples" size="20" maxlength="20"></td> </tr> <tr> <td>Home Runs:</td> <td><input type="text" name="homeRuns" size="20" maxlength="20"></td> </tr> <tr> <td>Runs Scored:</td> <td><input type="text" name="runsScrd" size="20" maxlength="20"></td> </tr> <tr> <td>Fielders Choice:</td> <td><input type="text" name="fieldersCh" size="20" maxlength="20"> </td> </tr> </table> <br /> <input type="submit" value="Submit" name="submit"> <input type="reset" value="Reset Values"> </form> <br /> <?php echo $records; ?> </div> <!--END CONTENT DIV--> </body> </html> [attachment deleted by admin]
  9. One quick thing I don't understand.....below where the HTML form comment is and there is a form method post statement.... <form method="post" action="">addTournament2.php How come the .php file is outside of the form method brackets?? How does that work? Everything else for the most part makes sense and its definitely in a hell of a lot more organized fashion. Perhaps as I become better at this I will be able to produce something similiar. Sigh. Sorry, bout that. I removed the file name from the action so I could have the page POST to itself for testing purposes. You can replace that value or leave it blank if the page is supposed top post to itself. // PROCESS FORM ON SUBMIT $response = ''; if (isset($_POST['tourneyName'])) No, no relation. In that code, I simply define $respons as an empty string in case it doesn't get defined later. The IF statement is there to process the data only if data was posted. Ok, thank you for that. It helps me better understand so I can try and correct in the future.....Now I have taken what you did and tried to apply it to another form.....its slightly different but should have almost the basic set up. I might post a new thread if I can't get it working! THANKS AGAIN!
  10. ok Cool. And that empty action="" refers to this at the very top right? // PROCESS FORM ON SUBMIT $response = ''; if (isset($_POST['tourneyName']))
  11. One quick thing I don't understand.....below where the HTML form comment is and there is a form method post statement.... <form method="post" action="">addTournament2.php How come the .php file is outside of the form method brackets?? How does that work? Everything else for the most part makes sense and its definitely in a hell of a lot more organized fashion. Perhaps as I become better at this I will be able to produce something similiar. Sigh.
  12. Dear mjdamato, Oh, how I love thee. Let me count the ways. That works perfectly!!! Thank you SOOOOO much. I would have spent another 6 hours trying to go around my you know what to get to my elbow. Thank you, thank you, thank you! I'm not sure how to do this but this thread has been solved! THANK YOU!!!!!!! WOOHOOO!!!!! PS. mjdamato is the bomb.
  13. Hey again, I didn't originally have the NULL in there.....there are 3 columsn in the table....tourneyID is the primary key. I wasn't sure whether i had to reference that or not? Its auto increment so I thought if i left that out and added data for the other 2 fields it would automatically insert a new id#? I tried your modified code w/ the added bracket and THIS TIME I got this error: Catchable fatal error: Object of class DateTime could not be converted to string in L:\addTournament2.php on line 17 I don't know what that means....but just wondering....my already existing dates in the database aren't time stamped...they are just date (yyyy-mm-dd) I think i was putting yyyy-mm-mm on those other posts. 'Excuse. I got 3 hours sleep last night.
  14. When I have tried to test the name/date in my form I have tried entering both yyyy-mm-mm AND mm-mm-yyyy and even yyyymmmm.
×
×
  • 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.