flashmonkey Posted February 9, 2008 Share Posted February 9, 2008 Hi Fellows! mysql update via form is not working. Here is the code: $id=$_GET['id']; if(isset($_POST['now']) && !empty($_POST['update'])){ $update=$_POST['update']; $query="UPDATE achv_tbl SET achv_desc='$update' WHERE achv_id='$id';"; $result=mysql_query($query)or die(mysql_error()); I have granted all priviledges to the username. I am using mysql version 5.0.45. I have also tried copying the update sql code from phpmyadmin but still it is not working. Any help/suggestions will be highly appreciated. Thankz in advance! EDIT: Changed subject to conform to forum policy. Quote Link to comment Share on other sites More sharing options...
thebadbad Posted February 9, 2008 Share Posted February 9, 2008 I think you have an extra semicolon at the end of the query. It should end achv_id='$id'";, I'm pretty sure. Well, I was wrong apparently. But remember to escape what's sent with the query with mysql_real_escape_string(), to avoid SQL injections. Quote Link to comment Share on other sites More sharing options...
revraz Posted February 9, 2008 Share Posted February 9, 2008 What is the error? Echo the $query to make sure it looks ok, maybe a variable is blank. And the semi colon is fine at the end. Quote Link to comment Share on other sites More sharing options...
flashmonkey Posted February 9, 2008 Author Share Posted February 9, 2008 No error appears on the mysql_error();. I have debugged the entire page multiple times and everything outputs correctly when i use echo "";. Entry/delete forms are working smoothly. I have also tried removing the extra ; but it still doesn't work. :'( Quote Link to comment Share on other sites More sharing options...
Barand Posted February 9, 2008 Share Posted February 9, 2008 Are you sure $id has a value (you use $_GET for that one) Quote Link to comment Share on other sites More sharing options...
flashmonkey Posted February 9, 2008 Author Share Posted February 9, 2008 ;D Solved the problem! Just removed the quotes from $id and the thing is working. Thankz to all who replied. Really appreciate it. ;D Quote Link to comment 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.