toothpick007 Posted March 21, 2012 Share Posted March 21, 2012 I have written some code to past information from one page to a diffrent page however all the variables are sent over but they are not writting to the database could anyone help me out please .... $ud_P_Id = $_POST['ud_P_Id']; $ud_LastName = $_POST['ud_LastName']; $ud_FirstName = $_POST['ud_FirstName']; $ud_GroupCode=$_POST['ud_GroupCode']; $ud_P_Unit1=$_POST['ud_P_Unit1']; $ud_P_Unit2=$_POST['ud_P_Unit2']; $ud_P_Unit3=$_POST['ud_P_Unit3']; $ud_P_Unit6=$_POST['ud_P_Unit6']; $ud_P_Unit14=$_POST['ud_P_Unit14']; $ud_P_Unit20=$_POST['ud_P_Unit20']; $ud_P_Unit27=$_POST['ud_P_Unit27']; $ud_P_Unit28=$_POST['ud_P_Unit28']; $ud_P_Unit42=$_POST['ud_P_Unit42']; $ud_P_Unit10=$_POST['ud_P_Unit10']; $ud_P_Unit11=$_POST['ud_P_Unit11']; $ud_P_Unit12=$_POST['ud_P_Unit12']; $ud_P_Unit13=$_POST['ud_P_Unit13']; $ud_P_Unit1454=$_POST['ud_P_Unit1454']; $ud_P_Unit15=$_POST['ud_P_Unit15']; $ud_P_Unit16=$_POST['ud_P_Unit16']; $ud_P_Unit17=$_POST['ud_P_Unit17']; $ud_P_Unit18=$_POST['ud_P_Unit18']; $con = mysql_connect('localhost', 'lccstude_progre', '********'); $db= "lccstude_pro"; if (! $con) die("Couldn't connect to MySQL"); mysql_select_db($db , $con) or die("Couldn't open $db: ".mysql_error()); mysql_query("UPDATE BTECL31113 SET FirstName='$ud_FirstName' , LastName='$ud_LastName' , GroupCode='$ud_GroupCode' , Unit1='$ud_P_Unit1' , Unit2='$ud_P_Unit2' , Unit3='$ud_P_Unit3' , Unit6='$ud_P_Unit6' , Unit14='$ud_P_Unit14' , Unit20='$ud_P_Unit20' , Unit27='$ud_P_Unit27' , Unit28='$ud_P_Unit28' , Unit42='$ud_P_Unit42' , Unit10='$ud_P_Unit10' , Unit11='$ud_P_Unit11' , Unit12='$ud_P_Unit12' , Unit13='$ud_P_Unit13' , Unit1454='$ud_P_Unit1454' , Unit15='$ud_P_Unit15' , Unit16= $ud_P_Unit16' , Unit17='$ud_P_Unit17' , Unit18='$ud_P_Unit18' WHERE P_Id='$ud_P_Id'"); echo "Record Updated"; mysql_close($con); Please any help would be great Quote Link to comment https://forums.phpfreaks.com/topic/259404-help-no-writing-to-database/ Share on other sites More sharing options...
Muddy_Funster Posted March 21, 2012 Share Posted March 21, 2012 so what exactly IS happening, and is there a reason you chose not to include the or die(mysql_error()) for the mysql_query? Quote Link to comment https://forums.phpfreaks.com/topic/259404-help-no-writing-to-database/#findComment-1329770 Share on other sites More sharing options...
requinix Posted March 21, 2012 Share Posted March 21, 2012 First things first: SQL injection. All those $_POST items need to be escaped before you can stick them into the query. They all need to look like $ud_P_Id = mysql_real_escape_string($_POST['ud_P_Id']; Move the database connection stuff to before all the assignments, then add mysql_real_escape_string() to all of them. Quote Link to comment https://forums.phpfreaks.com/topic/259404-help-no-writing-to-database/#findComment-1329771 Share on other sites More sharing options...
toothpick007 Posted March 21, 2012 Author Share Posted March 21, 2012 @Muddy I have got the die ... And nothing happens i get the echo statement on the page and i had other echos to see if the information is coming across which it is but its just not writting to the database for some strange reason ..... @Reqinix Done that but no change still not writing to the database .... Quote Link to comment https://forums.phpfreaks.com/topic/259404-help-no-writing-to-database/#findComment-1329777 Share on other sites More sharing options...
Muddy_Funster Posted March 21, 2012 Share Posted March 21, 2012 there is no die in here that I can see: mysql_query("UPDATE BTECL31113 SET FirstName='$ud_FirstName' , LastName='$ud_LastName' , GroupCode='$ud_GroupCode' , Unit1='$ud_P_Unit1' , Unit2='$ud_P_Unit2' , Unit3='$ud_P_Unit3' , Unit6='$ud_P_Unit6' , Unit14='$ud_P_Unit14' , Unit20='$ud_P_Unit20' , Unit27='$ud_P_Unit27' , Unit28='$ud_P_Unit28' , Unit42='$ud_P_Unit42' , Unit10='$ud_P_Unit10' , Unit11='$ud_P_Unit11' , Unit12='$ud_P_Unit12' , Unit13='$ud_P_Unit13' , Unit1454='$ud_P_Unit1454' , Unit15='$ud_P_Unit15' , Unit16= $ud_P_Unit16' , Unit17='$ud_P_Unit17' , Unit18='$ud_P_Unit18' WHERE P_Id='$ud_P_Id'"); echo "Record Updated"; Quote Link to comment https://forums.phpfreaks.com/topic/259404-help-no-writing-to-database/#findComment-1329821 Share on other sites More sharing options...
requinix Posted March 21, 2012 Share Posted March 21, 2012 @Reqinix Done that but no change still not writing to the database .... Good. Because now I'll tell you that there's a syntax error in your query. And with what Muddy told you to do, you should be able to see where it is. Quote Link to comment https://forums.phpfreaks.com/topic/259404-help-no-writing-to-database/#findComment-1329829 Share on other sites More sharing options...
PFMaBiSmAd Posted March 21, 2012 Share Posted March 21, 2012 There's another thread for this problem where all the same things were suggested. Quote Link to comment https://forums.phpfreaks.com/topic/259404-help-no-writing-to-database/#findComment-1329830 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.