twilitegxa Posted August 8, 2009 Share Posted August 8, 2009 This script is inserting the record into the first database (scouts) as expected, but it is also inserting a blank record afterwards. Can anyone tell me why? form: <?php session_start(); //Access Tracking Snippet //set up static variables $page_title = "fdark_warrior.php"; $user_agent = getenv("HTTP_USER_AGENT"); $date_accessed = date("Y-m-d"); //connect to server and select database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); $db = mysql_select_db("smrpg", $conn) or die(mysql_error()); //create and issue query $sql = "insert into access_tracker values ('', '$page_title', '$user_agent', '$date_accessed')"; mysql_query($sql,$conn); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sailor Moon RPG - Character Creation Form | Female Dark Warrior</title> <style type="text/css" media="screen"> /*<![CDATA[*/ @import url(global.css); /*]]>*/ </style> </head> <body> <!-- HEADER --> <h1 class="logo">Sailor Moon RPG</h1> <!-- /HEADER --> <?php include("topnav.php"); ?> <div id="main"> <?php include("includes/log.php"); ?> <?php include("mainnav.php"); ?> <form action="insert_fdark_warrior.php" method="post"> <h1>Step 2: Character Outline - Creation</h1> <h2><u>Female Dark Warrior Profile</u></h2> <table border="0"> <td>Character Name:</td> <td><input type="text" name="name" size="30" maxlength="100"></td> </tr> <tr> <td>Element Of Influence (if any):</td> <td> <SELECT NAME="element_of_influence" SIZE="1"> <OPTION value="Water">Water</OPTION> <OPTION value="Fire">Fire</OPTION> <OPTION value="Wood/Lightning">Wood/Lightning</OPTION> <OPTION value="Metal">Metal</OPTION> <OPTION value="Earth">Earth</OPTION> <OPTION value="Time">Time</OPTION> <OPTION value="None">None</OPTION> </SELECT> <a href="elements.php" title="Help!"><img src="question.gif" /></a></td> </tr> <tr> <td>Age:</td> <td><input type="text" name="age" size="2" maxlength="2"></td> </tr> <tr> <td>Date Of Birth:</td> <td><SELECT NAME="birth_month" SIZE="1"> <OPTION value="01">January</OPTION> <OPTION value="02">February</OPTION> <OPTION value="03">March</OPTION> <OPTION value="04">April</OPTION> <OPTION value="05">May</OPTION> <OPTION value="06">June</OPTION> <OPTION value="07">July</OPTION> <OPTION value="08">August</OPTION> <OPTION value="09">September</OPTION> <OPTION value="10">October</OPTION> <OPTION value="11">November</OPTION> <OPTION value="12">December</OPTION> </SELECT> <SELECT NAME="birth_date" SIZE="1"> <OPTION value="01">1</OPTION> <OPTION value="02">2</OPTION> <OPTION value="03">3</OPTION> <OPTION value="04">4</OPTION> <OPTION value="05">5</OPTION> <OPTION value="06">6</OPTION> <OPTION value="07">7</OPTION> <OPTION value="08">8</OPTION> <OPTION value="09">9</OPTION> <OPTION value="10">10</OPTION> <OPTION value="11">11</OPTION> <OPTION value="12">12</OPTION> <OPTION value="13">13</OPTION> <OPTION value="14">14</OPTION> <OPTION value="15">15</OPTION> <OPTION value="16">16</OPTION> <OPTION value="17">17</OPTION> <OPTION value="18">18</OPTION> <OPTION value="19">19</OPTION> <OPTION value="20">20</OPTION> <OPTION value="21">21</OPTION> <OPTION value="22">22</OPTION> <OPTION value="23">23</OPTION> <OPTION value="24">24</OPTION> <OPTION value="25">25</OPTION> <OPTION value="26">26</OPTION> <OPTION value="27">27</OPTION> <OPTION value="28">28</OPTION> <OPTION value="29">29</OPTION> <OPTION value="30">30</OPTION> <OPTION value="31">31</OPTION> </SELECT> </td> </tr> <tr> <td>Height:</td> <td><input type="text" name="height_feet" size="2" maxlength="2"> feet <input type="text" name="height_inches" size="2" maxlength="2"> inches</td> </tr> <tr> <td>Blood Type:</td> <td><input type="text" name="blood_type" size="4" maxlength="4"> <a href="bloodtype.php" title="Help!"><img src="question.gif" /></a> </td> </tr> <tr> <td>Hobbies:</td> <td><input type="text" name="hobbies" size="30" maxlength="100"> </td> </tr> <tr> <td>Favorite Color:</td> <td><input type="text" name="favorite_color" size="10" maxlength="30"> </td> </tr> <tr> <td>Favorite Gemstone:</td> <td><input type="text" name="favorite_gemstone" size="10" maxlength="10"> </td> </tr> <tr> <td>Favorite Food:</td> <td><input type="text" name="favorite_food" size="10" maxlength="30"> </td> </tr> <tr> <td>Least Favorite Food:</td> <td><input type="text" name="least_favorite_food" size="10" maxlength="30"> </td> </tr> <tr> <td>Strengths:</td> <td><input type="text" name="strengths" size="30" maxlength="100"> </td> </tr> <tr> <td>Weaknesses:</td> <td><input type="text" name="weaknesses" size="30" maxlength="100"> </td> </tr> <tr> <td>Goal:</td> <td><input type="text" name="goal" size="30" maxlength="100"> </td> </tr> <tr> <td>Mission:</td> <td><input type="text" name="mission" size="30" maxlength="100"> </td> </tr> <tr> <td>Character Biography:</td> <td><textarea name="biography" rows=7 cols=46></textarea> </td> </tr> </table> <p style="text-align: center" class="submit"><input type="submit" value="Create Character" /> <input type="reset" value="Reset" /></p> </form> </div> <?php include("bottomnav.php"); ?><!-- FOOTER --> <!-- FOOTER --> <div id="footer_wrapper"> <div id="footer"> <p>Sailor Moon and all characters are<br /> trademarks of Naoko Takeuchi.</p> <p>Copyright © 2009 Liz Kula. All rights reserved.<br /> A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p> <div id="foot-nav"> <ul> <li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li> <li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li> </ul> </div> </div> </div> <!-- /FOOTER --> </body> </html> insert: <?php session_start(); //function for determining birth_year function yearOfBirth ($day, $month, $age) { $now = strtotime('1992-03-23'); $yob = date('Y', $now) - $age; if (date('md', $now) < sprintf('%02d%02d', $month, $day)) $yob--; return $yob; } $year = yearOfBirth($_POST['birth_date'], $_POST['birth_month'], $_POST['age']); //end of function for determining birth_year ?> <?php //connect to server and select database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("smrpg", $conn) or die(mysql_error()); //create and issue first query; insert values into scouts table $add_fdark_warrior = "insert into fdark_warrior values ('', now(), '$_SESSION[userName]', '$_POST[name]', '$_POST[element_of_influence]', '$_POST[name]', '$_POST[age]', '$_POST[birth_month]', '$_POST[birth_date]', '$year', '$_POST[blood_type]', '$_POST[hobbies]', '$_POST[favorite_color]', '$_POST[favorite_gemstone]', '$_POST[favorite_food]', '$_POST[least_favorite_food]', '$_POST[strengths]', '$_POST[weaknesses]', '$_POST[mission]', '$_POST[goal]', '".mysql_real_escape_string($_POST['biography'])."', '$_POST[height_feet]', '$_POST[height_inches]')"; mysql_query($add_fdark_warrior, $conn) or die(mysql_error()); //get identity from last query $identity = $_POST['name']; //create and issue second query; insert values into stats table //$add_stats = "insert into stats values ('', '$identity', '$_POST[body]', '$_POST[mind]', '$_POST[soul]')"; //mysql_query($add_stats, $conn) or die(mysql_error()); //create and issue third query; insert values into derived_values table //$add_derived_values = "insert into derived_values values ('', '$identity', '$_POST[health]', '$_POST[energy]', '$_POST[acv1]', '$_POST[acv2]', '$_POST[dcv1]', '$_POST[dcv2]', '$_POST[total_cp]')"; //mysql_query($add_derived_values, $conn) or die(mysql_error()); //create message for user $msg = "<p>The character, <strong>$identity</strong> was created.</p>"; ?> <html> <head> <title>Sailor Moon RPG - New Character Created - <?php echo $identity; ?></title> <style type="text/css" media="screen"> /*<![CDATA[*/ @import url(global.css); /*]]>*/ </style> </head> <body> <!-- HEADER --> <h1 class="logo">Sailor Moon RPG</h1> <!-- /HEADER --> <?php include("topnav.php"); ?> <div id="main"> <?php include("includes/log.php"); ?> <?php include("mainnav.php"); ?> <h1>New Character Created - <?php echo $identity; ?></h1> <?php print $msg; ?> </div> <?php include("bottomnav.php"); ?><!-- FOOTER --> <!-- FOOTER --> <div id="footer_wrapper"> <div id="footer"> <p>Sailor Moon and all characters are<br /> trademarks of Naoko Takeuchi.</p> <p>Copyright © 2009 Liz Kula. All rights reserved.<br /> A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p> <div id="foot-nav"> <ul> <li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li> <li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li> </ul> </div> </div> </div> <!-- /FOOTER --> </body> </html> Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted August 8, 2009 Author Share Posted August 8, 2009 I am using PHP version 5.3.0 and I read that the globals feature has been deprecated. Is this what is effecting my records? Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted August 23, 2009 Author Share Posted August 23, 2009 I'm assuming the problem was an add-on for Firefox, because it was only happening in Firefox and I had recently installed a new add-on. When I removed the add-on, the problem stopped. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.