schwallie Posted March 2, 2007 Share Posted March 2, 2007 Was there possibly an update in PHP or MySQL that has caused this problem? I wrote this code a couple years ago and really haven't worked with PHP in the last couple of years, so now I am lost as to how to fix this code..If someone can help it would be greeattly appreciated! Edit: As you can see, I have changed and screwed with the variables a lot to see if one would work(as in just using $_Post or something) but none have worked..also now when I add stuff nothing happens, so it is more than likely stalling before it inserts anything into the DB now) What I am getting in my mysql is this; 566 <? $firstname ?> <? echo($lastname); ?> <? echo($grade); ?> <? $sex ?> 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 565 <? echo($firstname); ?> <? echo($lastname); ?> <? echo($grade); ?> <? echo($sex); ?> 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 This is the first page that sends it to process.php <?php include('header.php'); include('connect.php'); If($_POST['sex'] == '') { ?> <form action="enter.php" method="post"> <span class="small">Grade Level</span> <br> <input TYPE="radio" NAME="grade" VALUE="7">7th<br> <input TYPE="radio" NAME="grade" VALUE="8">8th<br> <input TYPE="radio" NAME="grade" VALUE="9" CHECKED>9th<br> <input TYPE="radio" NAME="grade" VALUE="10">10th<br> <input TYPE="radio" NAME="grade" VALUE="11">11th<br> <input TYPE="radio" NAME="grade" VALUE="12">12th<br> <br> <span class="small">Gender</span> <br> <input TYPE="radio" NAME="sex" VALUE="male" CHECKED>Male<br> <input TYPE="radio" NAME="sex" VALUE="female">Female<br> <br> <span class="small">First Name: </span><input type="text" name="firstname"> <br> <span class="small">Last Name: </span><input type="text" name="lastname"> <br> <br><input type="submit" value="Proceed"> </form> <?php } else { $grade = $_POST['grade']; $sex = $_POST['sex']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; ?> <form action="process.php" method="post"> <input type="hidden" name="sex" value="<? $_POST['sex'] ?>"> <input type="hidden" name="firstname" value="<? echo '$firstname' ?>"> <input type="hidden" name="lastname" value="<? echo($lastname); ?>"> <input type="hidden" name="grade" value="<? echo($grade); ?>"> <span class="small">Please Enter The Answers from questions 1 through 30</span> <br><br> <span class="small">Question 1: </span><input type="text" name="1"><br> <span class="small">Question 2: </span><input type="text" name="2"><br> <span class="small">Question 3: </span><input type="text" name="3"><br> <span class="small">Question 4: </span><input type="text" name="4"><br> <span class="small">Question 5: </span><input type="text" name="5"><br> <span class="small">Question 6: </span><input type="text" name="6"><br> <span class="small">Question 7: </span><input type="text" name="7"><br> <span class="small">Question 8: </span><input type="text" name="8"><br> <span class="small">Question 9: </span><input type="text" name="9"><br> <span class="small">Question 10: </span><input type="text" name="10"><br> <span class="small">Question 11: </span><input type="text" name="11"><br> <span class="small">Question 12: </span><input type="text" name="12"><br> <span class="small">Question 13: </span><input type="text" name="13"><br> <span class="small">Question 14: </span><input type="text" name="14"><br> <span class="small">Question 15: </span><input type="text" name="15"><br> <span class="small">Question 16: </span><input type="text" name="16"><br> <span class="small">Question 17: </span><input type="text" name="17"><br> <span class="small">Question 18: </span><input type="text" name="18"><br> <span class="small">Question 19: </span><input type="text" name="19"><br> <span class="small">Question 20: </span><input type="text" name="20"><br> <span class="small">Question 21: </span><input type="text" name="21"><br> <span class="small">Question 22: </span><input type="text" name="22"><br> <span class="small">Question 23: </span><input type="text" name="23"><br> <span class="small">Question 24: </span><input type="text" name="24"><br> <span class="small">Question 25: </span><input type="text" name="25"><br> <span class="small">Question 26: </span><input type="text" name="26"><br> <span class="small">Question 27: </span><input type="text" name="27"><br> <span class="small">Question 28: </span><input type="text" name="28"><br> <span class="small">Question 29: </span><input type="text" name="29"><br> <span class="small">Question 30: </span><input type="text" name="30"><br> <br><br> <input type="submit" value="Proceed"> </form> <?php } include('footer.php'); ?> </body> </html> process.php <?php include('header.php'); include('connect.php'); $firstname = $_POST['firstname']; $lastname= $_POST['lastname']; $sex = $_POST['sex']; $grade = $_POST['grade']; $sql=mysql_query("select * from information WHERE grade='$grade' AND firstname='$firstname' AND lastname='$lastname' AND sex='$sex'"); $numrows=mysql_num_rows($sql); if($numrows > 0) { mysql_query("UPDATE information SET ques1='".$_POST['1']."', ques2='".$_POST['2']."', ques3='".$_POST['3']."', ques4='".$_POST['4']."', ques5='".$_POST['5']."', ques6='".$_POST['6']."', ques7='".$_POST['7']."', ques8='".$_POST['8']."', ques9='".$_POST['9']."', ques10='".$_POST['10']."', ques11='".$_POST['11']."', ques12='".$_POST['12']."', ques13='".$_POST['13']."', ques14='".$_POST['14']."', ques15='".$_POST['15']."', ques16='".$_POST['16']."', ques17='".$_POST['17']."', ques18='".$_POST['18']."', ques19='".$_POST['19']."', ques20='".$_POST['20']."', ques21='".$_POST['21']."', ques22='".$_POST['22']."', ques23='".$_POST['23']."', ques24='".$_POST['24']."', ques25='".$_POST['25']."', ques26='".$_POST['26']."', ques27='".$_POST['27']."', ques28='".$_POST['28']."', ques29='".$_POST['29']."', ques30='".$_POST['30']."' WHERE grade='$grade' AND sex='$sex' AND firstname='$firstname' AND lastname='$lastname'"); } else { mysql_query("INSERT INTO information SET grade='$grade', sex='$sex', firstname='$firstname', lastname='$lastname', ques1='".$_POST['1']."', ques2='".$_POST['2']."', ques3='".$_POST['3']."', ques4='".$_POST['4']."', ques5='".$_POST['5']."', ques6='".$_POST['6']."', ques7='".$_POST['7']."', ques8='".$_POST['8']."', ques9='".$_POST['9']."', ques10='".$_POST['10']."', ques11='".$_POST['11']."', ques12='".$_POST['12']."', ques13='".$_POST['13']."', ques14='".$_POST['14']."', ques15='".$_POST['15']."', ques16='".$_POST['16']."', ques17='".$_POST['17']."', ques18='".$_POST['18']."', ques19='".$_POST['19']."', ques20='".$_POST['20']."', ques21='".$_POST['21']."', ques22='".$_POST['22']."', ques23='".$_POST['23']."', ques24='".$_POST['24']."', ques25='".$_POST['25']."', ques26='".$_POST['26']."', ques27='".$_POST['27']."', ques28='".$_POST['28']."', ques29='".$_POST['29']."', ques30='".$_POST['30']."'"); echo('<br><br><br><br><center><font size=3>Thank you for submitting a new student</font><font size=2><br> You will now be returned to the enter information page. </font> <META HTTP-EQUIV="refresh" content="1; URL=enter.php"> '); } ?> Link to comment https://forums.phpfreaks.com/topic/40859-problem-with-coding-which-worked-fine-last-year/ Share on other sites More sharing options...
craygo Posted March 2, 2007 Share Posted March 2, 2007 are you getting any error messages?? Try breaking up your statements and echo out an error message $sql = "UPDATE information SET ques1='".$_POST['1']."', ques2='".$_POST['2']."', ques3='".$_POST['3']."', ques4='".$_POST['4']."', ques5='".$_POST['5']."', ques6='".$_POST['6']."', ques7='".$_POST['7']."', ques8='".$_POST['8']."', ques9='".$_POST['9']."', ques10='".$_POST['10']."', ques11='".$_POST['11']."', ques12='".$_POST['12']."', ques13='".$_POST['13']."', ques14='".$_POST['14']."', ques15='".$_POST['15']."', ques16='".$_POST['16']."', ques17='".$_POST['17']."', ques18='".$_POST['18']."', ques19='".$_POST['19']."', ques20='".$_POST['20']."', ques21='".$_POST['21']."', ques22='".$_POST['22']."', ques23='".$_POST['23']."', ques24='".$_POST['24']."', ques25='".$_POST['25']."', ques26='".$_POST['26']."', ques27='".$_POST['27']."', ques28='".$_POST['28']."', ques29='".$_POST['29']."', ques30='".$_POST['30']."' WHERE grade='$grade' AND sex='$sex' AND firstname='$firstname' AND lastname='$lastname'"; mysql_query($sql) or die(mysql_error()); Let is know what the error is Ray Link to comment https://forums.phpfreaks.com/topic/40859-problem-with-coding-which-worked-fine-last-year/#findComment-197827 Share on other sites More sharing options...
schwallie Posted March 2, 2007 Author Share Posted March 2, 2007 Nothing happened there..I am going to break up all of them. I deleted everything in the database and when I just did one nothing happened, but it did go to the success screen and refreshed and all so it got all the way through the code. I will break up everything else and see if we get any errors, but hopefully someone sees something else. Link to comment https://forums.phpfreaks.com/topic/40859-problem-with-coding-which-worked-fine-last-year/#findComment-197829 Share on other sites More sharing options...
schwallie Posted March 2, 2007 Author Share Posted March 2, 2007 Ok, I got an error now when I put it on the second one(the one before the meta-refresh) 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 'sex'] ?>', firstname='', lastname=' Link to comment https://forums.phpfreaks.com/topic/40859-problem-with-coding-which-worked-fine-last-year/#findComment-197831 Share on other sites More sharing options...
craygo Posted March 2, 2007 Share Posted March 2, 2007 This line is wrong on your form page <input type="hidden" name="sex" value="<? $_POST['sex'] ?>"> should be <input type="hidden" name="sex" value="<? echo $_POST['sex']; ?>"> Try that As a matter of fact, check all those hidden field values, none of them are being passed. They should all be in this format <? echo $value; ?> Ray Link to comment https://forums.phpfreaks.com/topic/40859-problem-with-coding-which-worked-fine-last-year/#findComment-197838 Share on other sites More sharing options...
schwallie Posted March 5, 2007 Author Share Posted March 5, 2007 Hey, has this been changed recently? I just started the program up and when I went through it none of the values were echoing. It all worked last year, so did PHP get updated to change some values? Link to comment https://forums.phpfreaks.com/topic/40859-problem-with-coding-which-worked-fine-last-year/#findComment-199868 Share on other sites More sharing options...
schwallie Posted March 5, 2007 Author Share Posted March 5, 2007 Alright guys I updated everything and am getting this 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 'grade']; ?>', sex='', firstname=' <?php include('header.php'); include('connect.php'); If($_POST['sex'] == '') { ?> <form action="enter.php" method="post"> <span class="small">Grade Level</span> <br> <input TYPE="radio" NAME="grade" VALUE="7">7th<br> <input TYPE="radio" NAME="grade" VALUE="8">8th<br> <input TYPE="radio" NAME="grade" VALUE="9" CHECKED>9th<br> <input TYPE="radio" NAME="grade" VALUE="10">10th<br> <input TYPE="radio" NAME="grade" VALUE="11">11th<br> <input TYPE="radio" NAME="grade" VALUE="12">12th<br> <br> <span class="small">Gender</span> <br> <input TYPE="radio" NAME="sex" VALUE="male" CHECKED>Male<br> <input TYPE="radio" NAME="sex" VALUE="female">Female<br> <br> <span class="small">First Name: </span><input type="text" name="firstname"> <br> <span class="small">Last Name: </span><input type="text" name="lastname"> <br> <br><input type="submit" value="Proceed"> </form> <?php } else { $grade = $_POST['grade']; $sex = $_POST['sex']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; ?> <form action="process.php" method="post"> <input type="hidden" name="sex" value="<? echo $_POST['sex']; ?>"> <input type="hidden" name="firstname" value="<? echo $_POST['firstname']; ?>"> <input type="hidden" name="lastname" value="<? echo $_POST['lastname']; ?>"> <input type="hidden" name="grade" value="<? echo $_POST['grade']; ?>"> <span class="small">Please Enter The Answers from questions 1 through 30</span> <br><br> <span class="small">Question 1: </span><input type="text" name="1"><br> <span class="small">Question 2: </span><input type="text" name="2"><br> <span class="small">Question 3: </span><input type="text" name="3"><br> <span class="small">Question 4: </span><input type="text" name="4"><br> <span class="small">Question 5: </span><input type="text" name="5"><br> <span class="small">Question 6: </span><input type="text" name="6"><br> <span class="small">Question 7: </span><input type="text" name="7"><br> <span class="small">Question 8: </span><input type="text" name="8"><br> <span class="small">Question 9: </span><input type="text" name="9"><br> <span class="small">Question 10: </span><input type="text" name="10"><br> <span class="small">Question 11: </span><input type="text" name="11"><br> <span class="small">Question 12: </span><input type="text" name="12"><br> <span class="small">Question 13: </span><input type="text" name="13"><br> <span class="small">Question 14: </span><input type="text" name="14"><br> <span class="small">Question 15: </span><input type="text" name="15"><br> <span class="small">Question 16: </span><input type="text" name="16"><br> <span class="small">Question 17: </span><input type="text" name="17"><br> <span class="small">Question 18: </span><input type="text" name="18"><br> <span class="small">Question 19: </span><input type="text" name="19"><br> <span class="small">Question 20: </span><input type="text" name="20"><br> <span class="small">Question 21: </span><input type="text" name="21"><br> <span class="small">Question 22: </span><input type="text" name="22"><br> <span class="small">Question 23: </span><input type="text" name="23"><br> <span class="small">Question 24: </span><input type="text" name="24"><br> <span class="small">Question 25: </span><input type="text" name="25"><br> <span class="small">Question 26: </span><input type="text" name="26"><br> <span class="small">Question 27: </span><input type="text" name="27"><br> <span class="small">Question 28: </span><input type="text" name="28"><br> <span class="small">Question 29: </span><input type="text" name="29"><br> <span class="small">Question 30: </span><input type="text" name="30"><br> <br><br> <input type="submit" value="Proceed"> </form> <?php } include('footer.php'); ?> </body> </html> <?php include('header.php'); include('connect.php'); $firstname = $_POST['firstname']; $lastname= $_POST['lastname']; $sex = $_POST['sex']; $grade = $_POST['grade']; $sql=mysql_query("select * from information WHERE grade='".$_POST['grade']."' AND sex='".$_POST['sex']."' AND firstname='".$_POST['firstname']."' AND lastname='".$_POST['lastname']."'"); $numrows=mysql_num_rows($sql); if($numrows > 0) { $sql = "UPDATE information SET ques1='".$_POST['1']."', ques2='".$_POST['2']."', ques3='".$_POST['3']."', ques4='".$_POST['4']."', ques5='".$_POST['5']."', ques6='".$_POST['6']."', ques7='".$_POST['7']."', ques8='".$_POST['8']."', ques9='".$_POST['9']."', ques10='".$_POST['10']."', ques11='".$_POST['11']."', ques12='".$_POST['12']."', ques13='".$_POST['13']."', ques14='".$_POST['14']."', ques15='".$_POST['15']."', ques16='".$_POST['16']."', ques17='".$_POST['17']."', ques18='".$_POST['18']."', ques19='".$_POST['19']."', ques20='".$_POST['20']."', ques21='".$_POST['21']."', ques22='".$_POST['22']."', ques23='".$_POST['23']."', ques24='".$_POST['24']."', ques25='".$_POST['25']."', ques26='".$_POST['26']."', ques27='".$_POST['27']."', ques28='".$_POST['28']."', ques29='".$_POST['29']."', ques30='".$_POST['30']."' WHERE grade='$grade' AND sex='$sex' AND firstname='$firstname' AND lastname='$lastname'"; mysql_query($sql) or die(mysql_error()); } else { $sql2= "INSERT INTO information SET grade='".$_POST['grade']."', sex='".$_POST['sex']."', firstname='".$_POST['firstname']."', lastname='".$_POST['lastname']."', ques1='".$_POST['1']."', ques2='".$_POST['2']."', ques3='".$_POST['3']."', ques4='".$_POST['4']."', ques5='".$_POST['5']."', ques6='".$_POST['6']."', ques7='".$_POST['7']."', ques8='".$_POST['8']."', ques9='".$_POST['9']."', ques10='".$_POST['10']."', ques11='".$_POST['11']."', ques12='".$_POST['12']."', ques13='".$_POST['13']."', ques14='".$_POST['14']."', ques15='".$_POST['15']."', ques16='".$_POST['16']."', ques17='".$_POST['17']."', ques18='".$_POST['18']."', ques19='".$_POST['19']."', ques20='".$_POST['20']."', ques21='".$_POST['21']."', ques22='".$_POST['22']."', ques23='".$_POST['23']."', ques24='".$_POST['24']."', ques25='".$_POST['25']."', ques26='".$_POST['26']."', ques27='".$_POST['27']."', ques28='".$_POST['28']."', ques29='".$_POST['29']."', ques30='".$_POST['30']."'"; mysql_query($sql2) or die(mysql_error()); echo('<br><br><br><br><center><font size=3>Thank you for submitting a new student</font><font size=2><br> You will now be returned to the enter information page. </font> <META HTTP-EQUIV="refresh" content="1; URL=enter.php"> '); } ?> Link to comment https://forums.phpfreaks.com/topic/40859-problem-with-coding-which-worked-fine-last-year/#findComment-199961 Share on other sites More sharing options...
craygo Posted March 6, 2007 Share Posted March 6, 2007 Do you have an id field for your information table?? Ray Link to comment https://forums.phpfreaks.com/topic/40859-problem-with-coding-which-worked-fine-last-year/#findComment-200770 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.