Hamish Posted April 24, 2007 Share Posted April 24, 2007 Hi All, I have read the sections refering to the following error message "Cannot modify header information - headers already sent by " and have tried to follow their suggestions. The first part of the program returns the required data and populates the form, but after changes are made to the data and an attempt to process the form is made the error message is produced I believe from the start of the php code. I am just learning both PHP and MySQL and am unsure how to proceed so any pointers would be helpful. Regards Hamish <!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=iso-8859-1" /> <title>Update Programme Leader*</title> </head> <body> <?php ob_start(); // Connect database. include("opendbincludeA.php"); // ***** This part will process when you Click on "Submit" button ***** // Check, if you clicked "Submit" button if($_POST['Submit']){ // Get parameters from form. $ID_Number=$_POST['ID_Number']; $UCAS_Code=$_POST['UCAS_Code']; $CourseName=$_POST['CourseName']; $PLTitle=$_POST['PLTitle']; $PLFirstName=$_POST['PLFirstName']; $PLName=$_POST['PLName']; $PLemailAddress=$_POST['PLemailAddress']; $PLTelNo=$_POST['PLTelNo']; $PLContractStart=$_POST['PLContractStart']; $PLContractEnd=$_POST['PLContractEnd']; $PLActive=$_POST['PLActive']; // Do update statement. mysql_query("update P_Leader set UCAS_Code='$UCAS_Code', CourseName='$CourseName', PLTitle='$PLTitle', PLFirstName='$PLFirstName', PLName='$PLName', PLemailAddress='$PLemailAddress', PLTelNo='$PLTelNo', PLContractStart='$PLContractStart', PLContractEnd='$ContractEnd', PLActive='$PLActive' where ID_Number='$ID_Number'"); // Re-direct this page to updateZX.php. header("location:updateZX.php"); exit; } // ************* End update part ************* // *** Select data to show on text fields in form. *** // Get id parameter (GET method) from updateZX.php $ID_Number=$_GET['ID_Number']; // Get records in all columns from table where column id equal in $id and put it in $result. $result=mysql_query("select * from P_Leader where ID_Number='$ID_Number'"); // Split records in $result by table rows and put them in $row. $row=mysql_fetch_assoc($result); // Close database connection. ob_end_flush(); mysql_close(); ?> <!-- set this form to POST method and target this form to itself ($PHP_SELF;)--> <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>"> <p> <br /> UCAS Code : <!-- name of this text field is "UCAS_Code" --> <input name="UCAS_Code" type="text" id="UCAS_Code" value="<? echo $row['UCAS_Code']; ?>"/> <br /> Title : <!-- name of this text field is "CourseName" --> <input name="CourseName" type="text" id="CourseName" value="<? echo $row['CourseName']; ?>"/> <br /> Title : <!-- name of this text field is "PLTitle" --> <input name="PLTitle" type="text" id="PLTitle" value="<? echo $row['PLTitle']; ?>"/> <br /> First Name : <!-- name of this text field is "PLFirstName" --> <input name="PLFirstName" type="text" id="PLFirstName" value="<? echo $row['PLFirstName']; ?>"/> <br /> Name : <!-- name of this text field is "PLSName" --> <input name="PLSName" type="text" id="PLSName" value="<? echo $row['PLSName']; ?>"/> <br /> email : <!-- name of this text field is "PLemailAddress" --> <input name="PLemailAddress" type="text" id="PLemailAddress" value="<? echo $row['PLemailAddress']; ?>"/> <br /> Tel No : <!-- name of this text field is "PLTelNo" --> <input name="PLTelNo" type="text" id="PLTelNo" value="<? echo $row['PLTelNo']; ?>"/> <br /> Contract Start : <!-- name of this text field is "PLContractStart" --> <input name="PLContractStart" type="text" id="PLContractStart" value="<? echo $row['PLContractStart']; ?>"/> <br /> Contract End : <!-- name of this text field is "PLContractEnd" --> <input name="PLContractEnd" type="text" id="PLContractEnd" value="<? echo $row['PLContractEnd']; ?>"/> <br /> Active : <!-- name of this text field is "PLActive" --> <input name="PLActive" type="text" id="PLActive" value="<? echo $row['PLActive']; ?>"/> </p> <p> <input type="submit" name="Submit" value="Submit" /> </p> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/ Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 try taking out the exit; afterwards Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-237437 Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 Also, please read: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-237440 Share on other sites More sharing options...
Hamish Posted April 24, 2007 Author Share Posted April 24, 2007 Hi I have read the the Topic and also made the suggested change to "exit;" but my error message remains. Regards Hamish Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-237458 Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 remove: <!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=iso-8859-1" /> <title>Update Programme Leader*</title> </head> <body> that should solve your problem Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-237463 Share on other sites More sharing options...
Hamish Posted April 24, 2007 Author Share Posted April 24, 2007 Hi, Made change sorry no different. hamish Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-237477 Share on other sites More sharing options...
fanfavorite Posted April 25, 2007 Share Posted April 25, 2007 You need to make sure that if you use the buffer, that it starts before any html content. put ob_start at the very top of your page and make sure there are no spaces before the <?php. Also try putting ob_end_flush(); at the very bottom of your page and make sure there are no spaces after the ?>. Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-237745 Share on other sites More sharing options...
Hamish Posted April 25, 2007 Author Share Posted April 25, 2007 Hi All, I have made all the suggested changes to my code, and have checked for whitespace too. Is there some software that can check for errors in white space that I can run my code through? Otherwise I seem to be stuck with the same problem with the headers. Regards Hamish Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-237968 Share on other sites More sharing options...
MadTechie Posted April 25, 2007 Share Posted April 25, 2007 try this <!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=iso-8859-1" /> <title>Update Programme Leader*</title> </head> <body> <?php ob_start(); // Connect database. @include("opendbincludeA.php"); // ***** This part will process when you Click on "Submit" button ***** // Check, if you clicked "Submit" button if($_POST['Submit']) { // Get parameters from form. $ID_Number=$_POST['ID_Number']; $UCAS_Code=$_POST['UCAS_Code']; $CourseName=$_POST['CourseName']; $PLTitle=$_POST['PLTitle']; $PLFirstName=$_POST['PLFirstName']; $PLName=$_POST['PLName']; $PLemailAddress=$_POST['PLemailAddress']; $PLTelNo=$_POST['PLTelNo']; $PLContractStart=$_POST['PLContractStart']; $PLContractEnd=$_POST['PLContractEnd']; $PLActive=$_POST['PLActive']; // Do update statement. @mysql_query("update P_Leader set UCAS_Code='$UCAS_Code', CourseName='$CourseName', PLTitle='$PLTitle', PLFirstName='$PLFirstName', PLName='$PLName', PLemailAddress='$PLemailAddress', PLTelNo='$PLTelNo', PLContractStart='$PLContractStart', PLContractEnd='$ContractEnd', PLActive='$PLActive' where ID_Number='$ID_Number'"); // Re-direct this page to updateZX.php. header("location: updateZX.php"); exit; }else( // ************* End update part ************* // *** Select data to show on text fields in form. *** // Get id parameter (GET method) from updateZX.php $ID_Number=$_GET['ID_Number']; // Get records in all columns from table where column id equal in $id and put it in $result. $result=mysql_query("select * from P_Leader where ID_Number='$ID_Number'"); // Split records in $result by table rows and put them in $row. $row=mysql_fetch_assoc($result); ?> <!-- set this form to POST method and target this form to itself ($PHP_SELF;)--> <form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF; ?>"> <p> UCAS Code : <!-- name of this text field is "UCAS_Code" --> <input name="UCAS_Code" type="text" id="UCAS_Code" value="<?php echo $row['UCAS_Code']; ?>"/> Title : <!-- name of this text field is "CourseName" --> <input name="CourseName" type="text" id="CourseName" value="<?php echo $row['CourseName']; ?>"/> Title : <!-- name of this text field is "PLTitle" --> <input name="PLTitle" type="text" id="PLTitle" value="<?php echo $row['PLTitle']; ?>"/> First Name : <!-- name of this text field is "PLFirstName" --> <input name="PLFirstName" type="text" id="PLFirstName" value="<?php echo $row['PLFirstName']; ?>"/> Name : <!-- name of this text field is "PLSName" --> <input name="PLSName" type="text" id="PLSName" value="<?php echo $row['PLSName']; ?>"/> email : <!-- name of this text field is "PLemailAddress" --> <input name="PLemailAddress" type="text" id="PLemailAddress" value="<?php echo $row['PLemailAddress']; ?>"/> Tel No : <!-- name of this text field is "PLTelNo" --> <input name="PLTelNo" type="text" id="PLTelNo" value="<?php echo $row['PLTelNo']; ?>"/> <br /> Contract Start : <!-- name of this text field is "PLContractStart" --> <input name="PLContractStart" type="text" id="PLContractStart" value="<?php echo $row['PLContractStart']; ?>"/> <br /> Contract End : <!-- name of this text field is "PLContractEnd" --> <input name="PLContractEnd" type="text" id="PLContractEnd" value="<?php echo $row['PLContractEnd']; ?>"/> <br /> Active : <!-- name of this text field is "PLActive" --> <input name="PLActive" type="text" id="PLActive" value="<?php echo $row['PLActive']; ?>"/> </p> <p> <input type="submit" name="Submit" value="Submit" /> </p> </form> <?php // Close database connection. } ob_end_flush(); mysql_close(); ?> </body> </html> if this fails please comment out the ob_end_flush(); and ob_flush(); and post the errors Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-237992 Share on other sites More sharing options...
Hamish Posted April 25, 2007 Author Share Posted April 25, 2007 Hi MadTechie, Thanks for the trouble you have gone to. The programme does not now return the form details, My error messageis now is Parse error: parse error, unexpected ';' in line39 from $ID_Number=$_Get['ID_Number']; Hamish Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-237995 Share on other sites More sharing options...
MadTechie Posted April 25, 2007 Share Posted April 25, 2007 oooops updated <!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=iso-8859-1" /> <title>Update Programme Leader*</title> </head> <body> <?php ob_start(); // Connect database. @include("opendbincludeA.php"); // ***** This part will process when you Click on "Submit" button ***** // Check, if you clicked "Submit" button if($_POST['Submit']) { // Get parameters from form. $ID_Number=$_POST['ID_Number']; $UCAS_Code=$_POST['UCAS_Code']; $CourseName=$_POST['CourseName']; $PLTitle=$_POST['PLTitle']; $PLFirstName=$_POST['PLFirstName']; $PLName=$_POST['PLName']; $PLemailAddress=$_POST['PLemailAddress']; $PLTelNo=$_POST['PLTelNo']; $PLContractStart=$_POST['PLContractStart']; $PLContractEnd=$_POST['PLContractEnd']; $PLActive=$_POST['PLActive']; // Do update statement. @mysql_query("update P_Leader set UCAS_Code='$UCAS_Code', CourseName='$CourseName', PLTitle='$PLTitle', PLFirstName='$PLFirstName', PLName='$PLName', PLemailAddress='$PLemailAddress', PLTelNo='$PLTelNo', PLContractStart='$PLContractStart', PLContractEnd='$ContractEnd', PLActive='$PLActive' where ID_Number='$ID_Number'"); // Re-direct this page to updateZX.php. header("location: updateZX.php"); exit; }else{ // ************* End update part ************* // *** Select data to show on text fields in form. *** // Get id parameter (GET method) from updateZX.php $ID_Number=$_GET['ID_Number']; // Get records in all columns from table where column id equal in $id and put it in $result. $result=mysql_query("select * from P_Leader where ID_Number='$ID_Number'"); // Split records in $result by table rows and put them in $row. $row=mysql_fetch_assoc($result); ?> <!-- set this form to POST method and target this form to itself ($PHP_SELF;)--> <form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF; ?>"> <p> UCAS Code : <!-- name of this text field is "UCAS_Code" --> <input name="UCAS_Code" type="text" id="UCAS_Code" value="<?php echo $row['UCAS_Code']; ?>"/> Title : <!-- name of this text field is "CourseName" --> <input name="CourseName" type="text" id="CourseName" value="<?php echo $row['CourseName']; ?>"/> Title : <!-- name of this text field is "PLTitle" --> <input name="PLTitle" type="text" id="PLTitle" value="<?php echo $row['PLTitle']; ?>"/> First Name : <!-- name of this text field is "PLFirstName" --> <input name="PLFirstName" type="text" id="PLFirstName" value="<?php echo $row['PLFirstName']; ?>"/> Name : <!-- name of this text field is "PLSName" --> <input name="PLSName" type="text" id="PLSName" value="<?php echo $row['PLSName']; ?>"/> email : <!-- name of this text field is "PLemailAddress" --> <input name="PLemailAddress" type="text" id="PLemailAddress" value="<?php echo $row['PLemailAddress']; ?>"/> Tel No : <!-- name of this text field is "PLTelNo" --> <input name="PLTelNo" type="text" id="PLTelNo" value="<?php echo $row['PLTelNo']; ?>"/> <br /> Contract Start : <!-- name of this text field is "PLContractStart" --> <input name="PLContractStart" type="text" id="PLContractStart" value="<?php echo $row['PLContractStart']; ?>"/> <br /> Contract End : <!-- name of this text field is "PLContractEnd" --> <input name="PLContractEnd" type="text" id="PLContractEnd" value="<?php echo $row['PLContractEnd']; ?>"/> <br /> Active : <!-- name of this text field is "PLActive" --> <input name="PLActive" type="text" id="PLActive" value="<?php echo $row['PLActive']; ?>"/> </p> <p> <input type="submit" name="Submit" value="Submit" /> </p> </form> <?php // Close database connection. } ob_end_flush(); mysql_close(); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238014 Share on other sites More sharing options...
Hamish Posted April 25, 2007 Author Share Posted April 25, 2007 Hi MadTechie, The program now returns the form details, without the line breaks. But does not process update details nor when commenting out "ob_start" and "ob_end_flush" The same error message "Cannot modify header information - headers already sent by " PLupdate1.php:8" "PLupdate1.php on line 31" Hamish Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238018 Share on other sites More sharing options...
MadTechie Posted April 25, 2007 Share Posted April 25, 2007 of course, this should work! i forgot to move a chunk down PS that error message helped <?php ob_start(); // Connect database. @include("opendbincludeA.php"); // ***** This part will process when you Click on "Submit" button ***** // Check, if you clicked "Submit" button if($_POST['Submit']) { // Get parameters from form. $ID_Number=$_POST['ID_Number']; $UCAS_Code=$_POST['UCAS_Code']; $CourseName=$_POST['CourseName']; $PLTitle=$_POST['PLTitle']; $PLFirstName=$_POST['PLFirstName']; $PLName=$_POST['PLName']; $PLemailAddress=$_POST['PLemailAddress']; $PLTelNo=$_POST['PLTelNo']; $PLContractStart=$_POST['PLContractStart']; $PLContractEnd=$_POST['PLContractEnd']; $PLActive=$_POST['PLActive']; // Do update statement. @mysql_query("update P_Leader set UCAS_Code='$UCAS_Code', CourseName='$CourseName', PLTitle='$PLTitle', PLFirstName='$PLFirstName', PLName='$PLName', PLemailAddress='$PLemailAddress', PLTelNo='$PLTelNo', PLContractStart='$PLContractStart', PLContractEnd='$ContractEnd', PLActive='$PLActive' where ID_Number='$ID_Number'"); // Re-direct this page to updateZX.php. header("location: updateZX.php"); exit; }else{ // ************* End update part ************* // *** Select data to show on text fields in form. *** // Get id parameter (GET method) from updateZX.php $ID_Number=$_GET['ID_Number']; // Get records in all columns from table where column id equal in $id and put it in $result. $result=mysql_query("select * from P_Leader where ID_Number='$ID_Number'"); // Split records in $result by table rows and put them in $row. $row=mysql_fetch_assoc($result); ?> <!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=iso-8859-1" /> <title>Update Programme Leader*</title> </head> <body> <!-- set this form to POST method and target this form to itself ($PHP_SELF;)--> <form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF; ?>"> <p> UCAS Code : <!-- name of this text field is "UCAS_Code" --> <input name="UCAS_Code" type="text" id="UCAS_Code" value="<?php echo $row['UCAS_Code']; ?>"/> Title : <!-- name of this text field is "CourseName" --> <input name="CourseName" type="text" id="CourseName" value="<?php echo $row['CourseName']; ?>"/> Title : <!-- name of this text field is "PLTitle" --> <input name="PLTitle" type="text" id="PLTitle" value="<?php echo $row['PLTitle']; ?>"/> First Name : <!-- name of this text field is "PLFirstName" --> <input name="PLFirstName" type="text" id="PLFirstName" value="<?php echo $row['PLFirstName']; ?>"/> Name : <!-- name of this text field is "PLSName" --> <input name="PLSName" type="text" id="PLSName" value="<?php echo $row['PLSName']; ?>"/> email : <!-- name of this text field is "PLemailAddress" --> <input name="PLemailAddress" type="text" id="PLemailAddress" value="<?php echo $row['PLemailAddress']; ?>"/> Tel No : <!-- name of this text field is "PLTelNo" --> <input name="PLTelNo" type="text" id="PLTelNo" value="<?php echo $row['PLTelNo']; ?>"/> <br /> Contract Start : <!-- name of this text field is "PLContractStart" --> <input name="PLContractStart" type="text" id="PLContractStart" value="<?php echo $row['PLContractStart']; ?>"/> <br /> Contract End : <!-- name of this text field is "PLContractEnd" --> <input name="PLContractEnd" type="text" id="PLContractEnd" value="<?php echo $row['PLContractEnd']; ?>"/> <br /> Active : <!-- name of this text field is "PLActive" --> <input name="PLActive" type="text" id="PLActive" value="<?php echo $row['PLActive']; ?>"/> </p> <p> <input type="submit" name="Submit" value="Submit" /> </p> </form> <?php // Close database connection. } ob_end_flush(); mysql_close(); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238026 Share on other sites More sharing options...
Hamish Posted April 25, 2007 Author Share Posted April 25, 2007 Hi MadTechie, The program now processes the update form without any error messages. and returns to the Up Date Form However it does not change the data in the MySQL database fields. Regards Hamish Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238039 Share on other sites More sharing options...
MadTechie Posted April 25, 2007 Share Posted April 25, 2007 ok this i think is the root of the problem.. for testing comment out the ob_start(); and change <?php @mysql_query("update P_Leader set UCAS_Code='$UCAS_Code', CourseName='$CourseName', PLTitle='$PLTitle', PLFirstName='$PLFirstName', PLName='$PLName', PLemailAddress='$PLemailAddress', PLTelNo='$PLTelNo', PLContractStart='$PLContractStart', PLContractEnd='$ContractEnd', PLActive='$PLActive' where ID_Number='$ID_Number'"); // Re-direct this page to updateZX.php. header("location: updateZX.php"); exit; ?> to <?php $SQLq = "update P_Leader set UCAS_Code='$UCAS_Code', CourseName='$CourseName', PLTitle='$PLTitle', PLFirstName='$PLFirstName', PLName='$PLName', PLemailAddress='$PLemailAddress', PLTelNo='$PLTelNo', PLContractStart='$PLContractStart', PLContractEnd='$ContractEnd', PLActive='$PLActive' where ID_Number='$ID_Number'"; mysql_query($SQLq) or die("query error: $SQLq<br>".mysql_error()); // Re-direct this page to updateZX.php. exit; ?> and lets review the error, Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238045 Share on other sites More sharing options...
Hamish Posted April 25, 2007 Author Share Posted April 25, 2007 The program runs without error messages both with and without ob_start(); commented. The form appears to be processed but returns a blank screen showing "PLupdate1.php" in the address window against "PLupdate1.php?ID_Number=1029" which was showing before submit. Refreshing the form page shows no change to the database record, nor does checking through PHPMyAdmin. Hamish Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238062 Share on other sites More sharing options...
MadTechie Posted April 25, 2007 Share Posted April 25, 2007 was missing the ID_number <?php ob_start(); // Connect database. @include("opendbincludeA.php"); // ***** This part will process when you Click on "Submit" button ***** // Check, if you clicked "Submit" button if($_POST['Submit']) { // Get parameters from form. $ID_Number=$_POST['ID_Number']; $UCAS_Code=$_POST['UCAS_Code']; $CourseName=$_POST['CourseName']; $PLTitle=$_POST['PLTitle']; $PLFirstName=$_POST['PLFirstName']; $PLName=$_POST['PLName']; $PLemailAddress=$_POST['PLemailAddress']; $PLTelNo=$_POST['PLTelNo']; $PLContractStart=$_POST['PLContractStart']; $PLContractEnd=$_POST['PLContractEnd']; $PLActive=$_POST['PLActive']; // Do update statement. @mysql_query("update P_Leader set UCAS_Code='$UCAS_Code', CourseName='$CourseName', PLTitle='$PLTitle', PLFirstName='$PLFirstName', PLName='$PLName', PLemailAddress='$PLemailAddress', PLTelNo='$PLTelNo', PLContractStart='$PLContractStart', PLContractEnd='$ContractEnd', PLActive='$PLActive' where ID_Number='$ID_Number'"); // Re-direct this page to updateZX.php. $ID_Number=$_POST['ID_Number']; header("location: updateZX.php?ID_Number=$ID_Number"); exit; }else{ // ************* End update part ************* // *** Select data to show on text fields in form. *** // Get id parameter (GET method) from updateZX.php $ID_Number=$_GET['ID_Number']; // Get records in all columns from table where column id equal in $id and put it in $result. $result=mysql_query("select * from P_Leader where ID_Number='$ID_Number'"); // Split records in $result by table rows and put them in $row. $row=mysql_fetch_assoc($result); ?> <!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=iso-8859-1" /> <title>Update Programme Leader*</title> </head> <body> <!-- set this form to POST method and target this form to itself ($PHP_SELF;)--> <form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF; ?>"> <p> <input name="ID_Number" type="hidden" id="ID_Number" value="<?php echo $row['ID_Number']; ?>"/> UCAS Code : <!-- name of this text field is "UCAS_Code" --> <input name="UCAS_Code" type="text" id="UCAS_Code" value="<?php echo $row['UCAS_Code']; ?>"/> Title : <!-- name of this text field is "CourseName" --> <input name="CourseName" type="text" id="CourseName" value="<?php echo $row['CourseName']; ?>"/> Title : <!-- name of this text field is "PLTitle" --> <input name="PLTitle" type="text" id="PLTitle" value="<?php echo $row['PLTitle']; ?>"/> First Name : <!-- name of this text field is "PLFirstName" --> <input name="PLFirstName" type="text" id="PLFirstName" value="<?php echo $row['PLFirstName']; ?>"/> Name : <!-- name of this text field is "PLSName" --> <input name="PLSName" type="text" id="PLSName" value="<?php echo $row['PLSName']; ?>"/> email : <!-- name of this text field is "PLemailAddress" --> <input name="PLemailAddress" type="text" id="PLemailAddress" value="<?php echo $row['PLemailAddress']; ?>"/> Tel No : <!-- name of this text field is "PLTelNo" --> <input name="PLTelNo" type="text" id="PLTelNo" value="<?php echo $row['PLTelNo']; ?>"/> <br /> Contract Start : <!-- name of this text field is "PLContractStart" --> <input name="PLContractStart" type="text" id="PLContractStart" value="<?php echo $row['PLContractStart']; ?>"/> <br /> Contract End : <!-- name of this text field is "PLContractEnd" --> <input name="PLContractEnd" type="text" id="PLContractEnd" value="<?php echo $row['PLContractEnd']; ?>"/> <br /> Active : <!-- name of this text field is "PLActive" --> <input name="PLActive" type="text" id="PLActive" value="<?php echo $row['PLActive']; ?>"/> </p> <p> <input type="submit" name="Submit" value="Submit" /> </p> </form> <?php // Close database connection. } ob_end_flush(); mysql_close(); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238074 Share on other sites More sharing options...
Hamish Posted April 25, 2007 Author Share Posted April 25, 2007 The program runs without error messages, and now returns to the Update form. However no changes are made to the database and the refreshed page carries the original data. Hamish Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238083 Share on other sites More sharing options...
MadTechie Posted April 25, 2007 Share Posted April 25, 2007 can you add this // Do update statement. @mysql_query("update P_Leader set UCAS_Code='$UCAS_Code', CourseName='$CourseName', PLTitle='$PLTitle', PLFirstName='$PLFirstName', PLName='$PLName', PLemailAddress='$PLemailAddress', PLTelNo='$PLTelNo', PLContractStart='$PLContractStart', PLContractEnd='$ContractEnd', PLActive='$PLActive' where ID_Number='$ID_Number'"); die("update P_Leader set UCAS_Code='$UCAS_Code', CourseName='$CourseName', PLTitle='$PLTitle', PLFirstName='$PLFirstName', PLName='$PLName', PLemailAddress='$PLemailAddress', PLTelNo='$PLTelNo', PLContractStart='$PLContractStart', PLContractEnd='$ContractEnd', PLActive='$PLActive' where ID_Number='$ID_Number'"); // Re-direct this page to updateZX.php. $ID_Number=$_POST['ID_Number']; header("location: updateZX.php?ID_Number=$ID_Number"); exit; comment out the ob_start(); it should display update P_....... paste that into SQL in the phpMyAdmin, and let me know the results Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238089 Share on other sites More sharing options...
Hamish Posted April 25, 2007 Author Share Posted April 25, 2007 I get the following error from MyAdmin #1064 - 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 '@mysql_query("update P_Leader set UCAS_Code='$UCAS_Code', CourseName='$CourseNam' at line 1 Hamish Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238101 Share on other sites More sharing options...
MadTechie Posted April 25, 2007 Share Posted April 25, 2007 no no, re-read last post, but you paste the output from the webpage into myphpadmin it should be something like update P_Leader set UCAS_Code='4234', Cou....etc etc etc Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238104 Share on other sites More sharing options...
Hamish Posted April 25, 2007 Author Share Posted April 25, 2007 Magic!! Thank you very much MadTechie, the MySQL query pointed out to a typo in one of my fields in the database. On correcting the error everything works like clockwork. I have learnt a vast amount in the last few hours about how to find errors from you. Again thanks very much for all the time and trouble to resolve my stupid mistake. Hamish Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238129 Share on other sites More sharing options...
MadTechie Posted April 25, 2007 Share Posted April 25, 2007 cool, i assumed the header failed due to an error from the sql but breaking it down helps me and you please click solved Quote Link to comment https://forums.phpfreaks.com/topic/48528-solved-header-error/#findComment-238131 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.