Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/259404-help-no-writing-to-database/
Share on other sites

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.

@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 ....

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";

@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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.