Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialasaf omri
Courses Plus Student 2,784 PointsSomething wrong with my code , guys?
<?php
require('connection.php');
if(isset($_GET["food_update"])){
$food_update = $_GET["food_update"];
$calories_update = $_GET["calories_update"];
$id = $_GET["id_update"];
$query = "UPDATE food SET food='$food_update' , calories='$calories_update' WHERE id='$id_update'";
mysql_query($query) or die('cannot query');
}
?>
<form action="index.php" method="get">
ID=<input type="text" name="id_update"> <br>
FOOD:<input type="text" name="food_update"> <br>
CALORIES:<input type="text" name="calories_update">
<input type="submit" value="submit">
</form>
When i click submit , it just refreshes the page, weird. and does nothing on database
1 Answer
Marcus Parsons
15,719 PointsHey asaf omri,
I noticed that you are setting the id to "$id" instead of "$id_update" as you have in that SQL query string. You will want to update one of those sections to whichever variable name you need it to be because right now, "$id_update" can't be put into the database because it's undefined but "$id" is defined.