Updating in mysql
THE CODE $qur= "update `users` set `username`='".$_POST['username']."', `password`='".$_POST['password']."', `name`='".$_POST['name']."', `email`='".$_POST['emailid']."', `phone`='".$_POST['phoneno']."', `country`='".$_POST['country']."', `county`='".$_POST['county']."', `city`='".$_POST['city']."', `pincode`='".$_POST['zip']."', `shipping`='".$_POST['shipping']."', `billing`='".$_POST['billing']."', `organisation`='".$_POST['org']."', `fax`='".$_POST['fax']."' where id=".$_GET['id']; mysql_query( $qur) ; i tried using a common update command, but when i use it with mysql_error(), it reports the following error: You have an error in your SQL syntax, check the manual that corresponds to your My SQL server version for the right syntax to use near 'mod = '77' ,yod='8899' where ID =56 at line 1. and then the table (with the 'date' and 'year' column updated, but the 'month' column as it is...).. But you can check what are the values you are supplying, what are the table column data type, check are you sending null values or not, you may need to convert data to the right type.Try to print the query with echo $query_string_variable Then execute the query in the database by itself [not from PHP You can also try the other way...to write a query by providing static values and run the query into the database.So, the best solution would be to make a logfile and then process this file with a cron job.It’s very easy to do that, but the challenge lies in updating the database.Data storing in to database enables us to keep the information safe and secure, but what if we wish to update it. For this you must have a database in My SQL with the information stored in it. In this blog post we will show you how to update previously stored information in database using PHP.Here’s an example of logfile, with each view logged on a single line using this format: part is most important, since it’s the only file writing mode that can be used with multiple processes (remember that you have MANY viewers at the same time, and if only 2 of them try to write a file at the same time your file will be pretty much screwed – no, you don’t lose the file itself, you just lose the content, which is even more important).An alternative would be to use file locking, but it’s really really inefficient when you have lots of visitors (digg effect anyone? However, the append mode is optimized by the operating system and stores the content in a buffer, making sure the content is write properly.
When i use three seperate UPDATE commands, one for each column, FUNNILY, the first and the third columns get updated, and for some GOD KNOWS WHAT reason, the second column just refuses to change...
The query i used was :=- UPDATE client SET mod = '12' where ID = '1' with exactly the shown usage of (' '), but the error shows a certain different type of usage. I thought their presence would cause the query to fail by themselves (not in My SQL, I guess). Try renaming the mod field to modnum (or something similar) and executing: "update client set dod=$dod, modnum=$mod, yod=$yod where id=$id"; Well badbart, as nav33n said, you hit the nail on the head.