Welcome! Log In Create A New Profile

Advanced

UPDATING DATABASE

Posted by 46107894 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
UPDATING DATABASE
April 14, 2012 03:58PM
Hi Mac

All my code seems to be working just fine apart from the UPDATE statement. I can successfully delete a database entry by referring to the table row $ID variable, but when I try doing it with the UPDATE statement on my Edit page, it does nothing?

Some suggestions would be great. I will gladly forward a section of code for your viewing.

Thanks a bunch

Nick
avatar
Mac
Re: UPDATING DATABASE
April 16, 2012 06:44AM
Post the line containing your update query
Re: UPDATING DATABASE
April 16, 2012 04:27PM
Hi Mac

Below is the code. When the user presses the update button the variables are assigned and should be sent to the database but it doesn't seem to work?
Looked through text book, online and pdf files but cant figure it out.

Thanks


Language: PHP
// checks to see if update button pressed if ($_SERVER[';REQUEST_METHOD';] == ';POST';) { //assigns values in textareas to variables $type_id = $_GET[';type_id';]; $name = $_POST[';name';]; $origin = $_POST[';origin';]; $strength = $_POST[';strength';]; $price = $_POST[';price';];   //updates the database with name, origin, strength and price based on id variable $update = "UPDATE info SET name = $name, origin = $origin, strength = $strength, price = $price WHERE type_id = $type_id"; $result = mysql_query($update); print "<br>The coffee $name from $origin was succesfully updated.<br>Price: $price and Strength: $strength ."; }
avatar
Mac
Re: UPDATING DATABASE
April 17, 2012 06:43AM
Language: PHP
$update = "UPDATE info SET name = ';$name';, origin = ';$origin'; //etc.
Re: UPDATING DATABASE
April 17, 2012 01:28PM
Please Help. Can't seem to get the database data into the form. The form displays something like this: "<? echo $row['code'];?>". No values.

Language: PHP
//GET THE MODULE ID VALUE $module_id = $_GET[';module_id';];   //get data from database $result = mysql_query("SELECT * FROM module WHERE module_id = ';$module_id';") or die (mysql_error());   $row = mysql_fetch_array($result);
avatar
Mac
Re: UPDATING DATABASE
April 17, 2012 04:12PM
That means your server is not interpreting the php tags as php code, so it prints the code instead. Try <?php ?> tags
Re: UPDATING DATABASE
April 17, 2012 08:23PM
I feel like an idiot. Such a small thing had me stumped for so long.

Thanks for help, really enjoying PHP
Sorry, you do not have permission to post/reply in this forum.