quint Posted September 12, 2007 Share Posted September 12, 2007 i ave this problem with lines 89 and 90 returning the following errors Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\chris1\My Documents\xampp\htdocs\elp\modify_information.php on line 88 Warning: Cannot modify header information - headers already sent by (output started at C:\Documents and Settings\chris1\My Documents\xampp\htdocs\elp\modify_information.php:88) in C:\Documents and Settings\chris1\My Documents\xampp\htdocs\elp\modify_information.php on line 89 heres the code $RSStudent=$RSStudent_query=@mysql_query(("update OCStudents set StudentName = '" .$_POST["Name"]."', StudentEmailAddress = '" .$_POST["EmailAddress"]."', StudentPassword = '" .$_POST["Password"]."' where StudentID = " .$_SESSION['StudentID']),$conn); $RSStudent=mysql_fetch_array($RSStudent_query); ;header("Location: "."student_menu.php");} ?> 89 and 90 are in bold.... complete newbie to php using mysql xammp apache any thoughts appreciated thanks in advance quint Quote Link to comment https://forums.phpfreaks.com/topic/69042-oh-headaches/ Share on other sites More sharing options...
frost Posted September 12, 2007 Share Posted September 12, 2007 Looks like you have a double semicolon $RSStudent=mysql_fetch_array($RSStudent_query); ;header("Location: "."student_menu.php");} Remove the semicolon from the start of that header line. that might do it. let me know. Quote Link to comment https://forums.phpfreaks.com/topic/69042-oh-headaches/#findComment-347084 Share on other sites More sharing options...
quint Posted September 12, 2007 Author Share Posted September 12, 2007 tried that made no difference..thanks Quote Link to comment https://forums.phpfreaks.com/topic/69042-oh-headaches/#findComment-347087 Share on other sites More sharing options...
quint Posted September 12, 2007 Author Share Posted September 12, 2007 heres full code <? session_start(); session_register("StudentID_session"); session_register("blnIsUserGood_session"); session_register("studentid_session"); ?> <? // asp2php (vbscript) converted on Tue Sep 11 21:05:05 2007 ?> <? if (empty($_SESSION['StudentID'])) { header("Location: "."index.php"); } if (empty($_POST["Submit"])) { //first time entering page // $conn is of type "adodb.connection" $conn=mysql_connect("localhost","root",""); mysql_select_db("elp",$conn); $RSStudent=$RSStudent_query=mysql_query(("SELECT StudentName, StudentEmailAddress, StudentPassword FROM OCStudents where StudentID = ".$_SESSION['StudentID']),$conn); $RSStudent=mysql_fetch_array($RSStudent_query); ; $TheMessage="Modify your student information and press OK."; $StudentName=$RSStudent["StudentName"]; $StudentEmailAddress=$RSStudent["StudentEmailAddress"]; $StudentPassword=$RSStudent["StudentPassword"]; } else if (empty($_POST["Name"]) || $_POST["Name"]=="") { $TheMessage="Name is required."; $StudentName=$_POST["Name"]; $StudentEmailAddress=$_POST["EmailAddress"]; $StudentPassword=$_POST["Password"]; } else if (empty($_POST["EmailAddress"]) || $_POST["EmailAddress"]=="") { $TheMessage="Email is required."; $StudentName=$_POST["Name"]; $StudentEmailAddress=$_POST["EmailAddress"]; $StudentPassword=$_POST["Password"]; } else if (empty($_POST["Password"]) || $_POST["Password"]=="") { $TheMessage="Password is required."; $StudentName=$_POST["Name"]; $StudentEmailAddress=$_POST["EmailAddress"]; $StudentPassword=$_POST["Password"]; } else if (empty($_POST["RepeatPassword"]) || $_POST["RepeatPassword"]=="") { $TheMessage="Repeat Password is required."; $StudentName=$_POST["Name"]; $StudentEmailAddress=$_POST["EmailAddress"]; $StudentPassword=$_POST["Password"]; } else if ($_POST["Password"]!=$_POST["RepeatPassword"]) { $TheMessage="Both passwords do not match!"; $StudentName=$_POST["Name"]; $StudentEmailAddress=$_POST["EmailAddress"]; $StudentPassword=$_POST["Password"]; } else { // $conn is of type "adodb.connection" $conn=mysql_connect("localhost","root",""); mysql_select_db("elp",$conn); $RSStudent=$RSStudent_query=@mysql_query(("update OCStudents set StudentName = '" .$_POST["Name"]."', StudentEmailAddress = '" .$_POST["EmailAddress"]."', StudentPassword = '" .$_POST["Password"]."' where StudentID = " .$_SESSION['StudentID']),$conn); $RSStudent=mysql_fetch_array($RSStudent_query); header("Location: "."student_menu.php");} ?> line 89 an 90 in bold Quote Link to comment https://forums.phpfreaks.com/topic/69042-oh-headaches/#findComment-347091 Share on other sites More sharing options...
wildteen88 Posted September 12, 2007 Share Posted September 12, 2007 Your header error is caused by the first error, which is: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\chris1\My Documents\xampp\htdocs\elp\modify_information.php on line 88 When you get the above type of error it basically means that you have error in your query. Id change these lines: $RSStudent=$RSStudent_query=@mysql_query(("update OCStudents set StudentName = '" .$_POST["Name"]."', StudentEmailAddress = '" .$_POST["EmailAddress"]."', StudentPassword = '" .$_POST["Password"]."' where StudentID = " .$_SESSION['StudentID']),$conn); $RSStudent=mysql_fetch_array($RSStudent_query); header("Location: "."student_menu.php");} Into: $RSStudent_query = "UPDATE OCStudents SET StudentName = '" . $_POST['Name'] . "', StudentEmailAddress = '" . $_POST["EmailAddress"] . "', StudentPassword = '" . $_POST["Password"] . "' WHERE StudentID = " . $_SESSION['StudentID']; $RSStudent_result = mysql_query($RSStudent_query, $conn) or die('SQL Error:<br />' . $RSStudent_query . '<br />' . mysql_error($conn)); $RSStudent = mysql_fetch_array($RSStudent_result); header("Location: student_menu.php"); } Re run you code. If there is an error with your query an error message will appear showing the query being ran and the reason for the error. Also I notice you are using POST data in your query. I strongly advise you to validate any user input (GET, POST, COOKIE) etc before using it within a query. Look into SQL Injection. Quote Link to comment https://forums.phpfreaks.com/topic/69042-oh-headaches/#findComment-347184 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.