| | |
updating multiple columns in single MySQL table
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
I think the update commands with three column update should work fine. 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 [I mean in mysql console/GUI/Mysql Browser/PhpMyAdmin].
] and see if it runs or what kind of errors it provides
You can also try the other way....try to write a query by providing static values and run the query into the database. if the query runs take it and use variables to provide the values. See what it does. Also, print these query and execute in the backend database [I mean in mysql console/GUI/Mysql Browser/PhpMyAdmin].
Try to print the query with
echo $query_string_variable
Then execute the query in the database by itself [not from PHP [I mean in mysql console/GUI/Mysql Browser/PhpMyAdmin].
] and see if it runs or what kind of errors it provides
You can also try the other way....try to write a query by providing static values and run the query into the database. if the query runs take it and use variables to provide the values. See what it does. Also, print these query and execute in the backend database [I mean in mysql console/GUI/Mysql Browser/PhpMyAdmin].
http://computer.justEtc.net - Free short notes, books, training videos on Business and Computer
•
•
Join Date: Jun 2008
Posts: 46
Reputation:
Solved Threads: 0
•
•
•
•
I think the update commands with three column update should work fine. 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 [I mean in mysql console/GUI/Mysql Browser/PhpMyAdmin].
] and see if it runs or what kind of errors it provides
You can also try the other way....try to write a query by providing static values and run the query into the database. if the query runs take it and use variables to provide the values. See what it does. Also, print these query and execute in the backend database [I mean in mysql console/GUI/Mysql Browser/PhpMyAdmin].
•
•
•
•
Strange! Now, execute this query in mysql console or phpmyadmin. If it still doesn't update, check the column datatype.I don't see any problem with the query.
Well, i tried running the query using the MySQL GUI (NaviCAT) wioth static data. Again, the same problem arises. The query runs perfectly well for 'dod' and 'yod', but when i run it for 'mod', it shows the error,
You have an error in your SQL syntax, check the manuala that corresponds to your MySQL server version for the right syntax to use near 'mod = '12' where ID = '1" at line 1
PS... 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.
PS2-- I have also tried using 'text' for the defintion of the 3 columns in the table, and hav even tried int(the 3 cols are basically for date, month and year)... but both produce the same results.
somebody pls suggest sumthing... this is getting really fustrating...
thx nav33 and sayedjustetc for your time n effort.
•
•
Join Date: Sep 2007
Posts: 12
Reputation:
Solved Threads: 1
Why are you using single quotes around the variables in your queries? If the fields are integers, they don't require string indicators. I thought their presence would cause the query to fail by themselves (not in MySQL, I guess). Is the ID field also an integer?
Oh, and isn't "mod" a PHP or MySQL reserved word? That could very well be the other part of your problem.
Try renaming the mod field to modnum (or something similar) and executing:
"update client set dod=$dod, modnum=$mod, yod=$yod where id=$id";
Oh, and isn't "mod" a PHP or MySQL reserved word? That could very well be the other part of your problem.
Try renaming the mod field to modnum (or something similar) and executing:
"update client set dod=$dod, modnum=$mod, yod=$yod where id=$id";
Last edited by badbart; Jul 7th, 2008 at 1:15 pm.
•
•
•
•
Oh, and isn't "mod" a PHP or MySQL reserved word? That could very well be the other part of your problem.
mysql Syntax (Toggle Plain Text)
UPDATE client SET dod='10', `MOD`='4',yod='2008' WHERE id='120'
Cheers,
Naveen
Edit: mod is a mysql reserve word.
Last edited by nav33n; Jul 7th, 2008 at 1:41 pm.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Jun 2008
Posts: 46
Reputation:
Solved Threads: 0
•
•
•
•
Oh, and isn't "mod" a PHP or MySQL reserved word? That could very well be the other part of your problem.
a big thx also to nav33n and to sayedjustetc for their time and effort.... thnk u guys... thx a lot...
![]() |
Similar Threads
Other Threads in the PHP Forum
- Previous Thread: Help!!!! open source SMS Shopping Project
- Next Thread: update data through dropdown
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error fcc file files folder form forms function functions google howtowriteathesis href htaccess html image include insert integration ip java javascript joomla limit link login loop mail menu methods mlm mod_rewrite multiple multipletables mysql oop open parse paypal pdf php problem provider query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table template tutorial update upload url validation validator variable video web xml youtube







I don't see any problem with the query.