Hi, I have a DB which has a "longtext" field. When I try to update the text in here, nothing changes. This is the query: <?php //connect to db //get input. mysql_query("UPDATE table SET myt='$myt' WHERE Fid='5'"); ?> I have checked the form input, and even modified another field with the same query, (int), but the longtext one doesn't update. What is the problem here? Google search for "longtext update mysql" returns some mentions of bugs, but I'm not sure. Can someone please tell me what am I doing wrong? Thanks for any help Bye
<? mysql_query("UPDATE table SET myt='$myt' WHERE Fid='5'") or die(mysql_error()); ?> PHP: Whats the actual error ?
Yes, the $myt has a value. I checked the input... And there's no actual display of the error, just that the DB won't update... If I run the following: <?php mysql_query("Update table SET another='$another' WHERE Fid='5'"); //another is some other int, varchar field. mysql_query("Update table SET myt='$myt' WHERE Fid='5'"); ?> The first field is getting updated, but the second one which is "longtext" won't update. No errors either... Not sure why this is happenning. Should I change it to TEXT instead of longtext? How many characters can "TEXT" field hold? Thanks Bye
I think it's the bug in MySQL. Try to test it on the newer MySQL version. TEXT column can hold up to 64KB.
That's what I thought after reading some of those google results. I will contact my host for a mysql update. By the way, will 64KB be enough to hold like 11,000 characters including spaces? Edit---- Just did a little check, and 64KB is good for almost 60,000 characters including new lines and spaces. (Typed in notepad.) ---- Thanks Bye
Try three things First try and echo the query to see whether it prints $myt's value: echo "UPDATE table SET myt='$myt' WHERE Fid='5'"; Code (markup): Second try and remove the quotation marks around 5: mysql_query("UPDATE table SET myt='$myt' WHERE Fid=5"); Code (markup): Third confirm that fid 5 actually exists.
Thanks for all the answers! Actually it was something with the "longtext". Altered the table field to "TEXT" and the original code works fine. BTW, if "FID" did not exist, or was empty, the other query would also not have worked. The UPDATE was actually being done by one query. But it didn't work, so I broke down the query into individual updates to see which field is creating the problem. Original was: <?php //connect //get input, check. mysql_query("UPDATE table SET field1='$f1', field2='$f2', field3='$f3' WHERE Fid='5'") or die(mysql_error()); ?> Thank you so much to all of you for helping and looking into this matter. Bye