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. Link to comment https://forums.phpfreaks.com/topic/90253-help-me-mysql-update-problem/ 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. Link to comment https://forums.phpfreaks.com/topic/90253-help-me-mysql-update-problem/#findComment-462708 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. Link to comment https://forums.phpfreaks.com/topic/90253-help-me-mysql-update-problem/#findComment-462709 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. :'( Link to comment https://forums.phpfreaks.com/topic/90253-help-me-mysql-update-problem/#findComment-462720 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) Link to comment https://forums.phpfreaks.com/topic/90253-help-me-mysql-update-problem/#findComment-462722 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 Link to comment https://forums.phpfreaks.com/topic/90253-help-me-mysql-update-problem/#findComment-462729 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.