shiza Posted June 26, 2012 Share Posted June 26, 2012 if(!mysql_query("INSERT INTO voter(encrypt) VALUES('$encrypted')",$con)) { echo "not executed"; } But it is not executed... $encrypted is about 5000 chararcters..and the data type of encrypt is Longtext. Quote Link to comment https://forums.phpfreaks.com/topic/264793-unable-to-insert-long-text-in-mysql-through-php/ Share on other sites More sharing options...
Barand Posted June 26, 2012 Share Posted June 26, 2012 Ask mysql why not withmysql_error() if(!mysql_query("INSERT INTO voter(encrypt) VALUES('$encrypted')",$con)) { echo "not executed<br>" . mysql_error(); } Quote Link to comment https://forums.phpfreaks.com/topic/264793-unable-to-insert-long-text-in-mysql-through-php/#findComment-1357030 Share on other sites More sharing options...
shiza Posted June 26, 2012 Author Share Posted June 26, 2012 It shows the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?~M?x??????~L=??\nn?E zR?S?R?]}?/sG?WG?x??G?5T6?%??M??O??? ?????V? W?!' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/264793-unable-to-insert-long-text-in-mysql-through-php/#findComment-1357032 Share on other sites More sharing options...
shiza Posted June 26, 2012 Author Share Posted June 26, 2012 The Value of $encrypted is: ?kpt%?pg? z?-?0#;f@$????Kv?8?!?>?3C????Qv????f)?,??????\?????^+7??i?P???Z?W??y.??r????$??y?x????&???a ?!?[c???iH5???K?A??u??L?gz?lY-??1E+??69???K!???UCQ? ?E?g???hp/>2y??)???D????y ??u 8??e?:Jf]?w?(????>???,?????#??d???-f? hSl?2B?ri=k???q???L?A$&2<??j ?4?fx??q6{{?Y?t.???????H???c&?]Z? ?`?$iH?\E??-*^??{???Z???3??~c????] w?Y&{?5?/?v?L????K H?@#?<????%f?_-??"?nP0IM??L?} N?g??2m2?2)?<?-U?Q|s??I+-1??^6? ?C?o?n?m?t"}u?z~??|-?R?q??U$|G?Ty|K?????? T?'?~M?x??????~L=??\nn?E zR?S?R?]}?/sG?WG?x??G?5T6?%??M??O??? ?????V? W?!??????2??E?? ???1??.? ? ????? ??s?5??_?I ^Gj???Z?pe???h?^+?Ö@-k?7??????1C?w?:???????d???s "??=?t?r????D??????5 ?C??|?? ?-????????r?{?ht@??????????i?qf;???^&???~}??@??h???\?h?&?????R? f{N????a>?I???????_?????db&|??U???'n??+????|??Ds??{???3????????:j?=/N&? 8??? ??????;7????g?:??+X?KN??k 7~?S??4Z???F??? ?o? =:~t%?2??R>??????A?n?si????k???N???.:l?GX????+o??KPbD<?vo? ?2?^?Q???ZH~?!????}H'???]??? b?]??? ?< R?K7??|?/zaug`w1??S?????(?d??9P6- 9?p????????u"?9V9?%s?7?W????Iv?,?>b?$?,?s???ue9??1?Z?p}?|?3?zZ?????%c?? ?!??W?f?K)=%;?k+R5Z???lZ.@{???A(?S? ????l??;???T??;`)???:H?H??0??1 &?y???G???gA??_???e<???;??W????z/%?`???6?????>?6?.??@G>?J??R<??i'??? ?q??i?,?41??K_?? #K">?4q^??n=`?!?i~{??u??[?%H?N lJ??da????n ?c ??y ?{|&?x?>???q%?>??T6Z?????DA????8ws???g7j?}A[????e??q7?'?p"??hph??h?O??_q???/%???8a?6A????????w??????2?O???Yg2U}?}???6rc??t???????*]?+?(V/b??C?: ????eq?x$????/w?l???@SHw?-u?3?G ?Ky?g?HWy?Y???h/?{we??5B?L?U?tyr?< ???J?>S?Y`j??????W8 ??#???`i)b?^~??T???Z?|??f?Y??^^?????%X;?c}???R????|j??7S??"?$C????kO];?&"\?K$$??*?2??>?n?V?$???/??]z????Q???u4?? ?}??_ ?H\f??P??#?????f?e*:dY0?<?o.?Lm??57>?u???y??H?P?zs???O???]?'?????V?vXf???"f ?b?dK??l,?X?g?4??d???;?_[?#??????#g~~?$U??C?:-?(*?%d?E+?_?-???g@?{L???8?????~?J????)X?3)Z????m?? cQ????wC2!??%R???@??7???????g?Tg gg?????Wj?:?~?? WSm?9???S??A???i+??rV????:I?kJ}h?{??DO?*l??o sS??,??f?!?2_/J??i??????`-???????o?Z??S??????9??????ü?.?4??[u^??,?W?h???G?_???gL "??"Gu?f?v?????Z(????????p?{?b? V)??NK?^?.?aw?????*??W??my?[?3?*????Gz???@0:?y?R?H ?{?M?w%Ui >????X?5??2L? ????5?q???R?I R? ??????^x'??{>?8?0????????z\??[xq???E????'?#RX g??gx#??IiF??Z????Z????j????????*3???j?????4(8 Q?qG???4?a?2br?7????,?x????Aç??E?C?_ ???8?Q?C??'LAB?d-?F?S=;t+h|??? ?~??????k=#?d???T9????v??????e?v5??C?Gc??"?c??????D]qY?5?)???VGB??)&????Kg)??R??a?|a???X?'?J?t?:???X?s??"??4:????6h%z?cE??M8?????+WO???E???s???T?3??+???#^?b?t?"s????>????????pk??Y??!'???(?(?p7tc?!?x[Q??V?#??A* =????????? ?38+q&^?????{dvc?\-/{9??g??D??'?, "f# ?c??C?>?w??w.l??+#??A??=o?;???.???????E?{ ?f?G???!|?U??T? ???c?????j<?Q?;???vVw(???/T??!{???97Gj ?9}`F? ]??m????m^??? ?X???C????DwP?o~??_6??,U???H5n?UQ?A????Q??Y??\?7*{???b|>eu???~1??K_?/?Q4$????z??A1??'=?<?e?"?7?? ?&]? j??#Q#??!??i??J?o:R??g?X-?u?w??? by ????\yf??7?*?n?n?????L+n?g?????< ??490t?R5+e?????8???2?lA??v?4e%???=V{ ?????; ??}q9?6??rTo;q????hX?Re???fa?6??L V??5 m@?;?$"?6?l? ????GT??Y&c????????T9i?Q??\z????*?q??^?4Q?}???? ??1??9 ?1??? ?n>u@7?????`?????=CQ? ??oH??Aq???O? ?1V?!?V??DFYk?%ta??|????%?1?+??\?f?V?????*g>*????V!?;?Mc} rE??an???6??I??\:??Y3,7e9?????0&?D???`HP??$?[sz?3?R????G?R?? ?410I??0{<pj?%?W?F?<@O??Y??? $?????@?@??4F? u?8???2??w7?l???(H'??{i??~??z???1T??A???,?8? F??? ?^P?0???C????iv u>j ?Qnb???1&??;???0mR4?[?]????UR??,m??5?/{?Pm???????7$??c???\b4h????Xi????????Ð?>??au?%?~N???2?g&??K?^??=?{"?9?????]? ?V??P??S?}?Liv?y2??????<?i? ?6 ws]?+?z??e?Sz?{*?<?BW???&w{???b??rS|??E?2??q?n&??/?ã?? r?3?v?j??i????mZ??l?2?] ????8???;,X M?O?2?=Y? <?7??`?SV???]i?? ?4???GY*??|"??!U???o?a??D|?[??% ?VW?????2???m??1?? ???????!Sq??Lt??6\?fT^?H[???i?[?p????G~? ?e??????c;? ????P??K<:?6 t??v<???v??????????D????l<???iS#Q ~????r?U????'%?hsm???OW????.*??x?+??>²D?{m+??O???Iu????>??D?V?B???H?(/<?^?*??? ?4.??VT??s?~?N??Lu;;^;ã?~AW?>w?L4??c??l?f???SG?tO5???0K?Sp? ?t?>(??? ???-:y q1??8??Y??|F???~?{?n M?????c ?@J?O???%0O?.??N??jT????H,?a+?^!?_ A ??Q ?Cl>$?&?j????M#??>?I??[?MH_???x1_?s $V?^t3)???:??0_ymn P$S?;?????b?ov5? ?U?dX??~)EQc??:?!??E??zR"Ac??]?? ?)#?xaTXK?&?F s?83)??5?&????R&?G?"???@?i4??????hh0??r??5#?e?j???QAzn?????V{??L??NK@???#xG?/?6s??r???CpC??99t_ ????4c;???Y?$??x??*??q????`?????????b??a??{C???z:??xz?=]f?? |z?$ O?i??? v??D????e??k?????e6??Q@??? ??/[j??P?Q?~'?y=?t?FZ?xw9 ??4?? y.???C??&??Ip>???????O?7;?h?????W5`(?!q# ???A?c??Il???h??h? ?u6FG#?\; ?Q??t?i??f?Ab??c??|?|?7?H?v?c???L'?) L?ge???? !V*?bQO?i???4 |5?}?g?z???!5?F]2N??%C??}?e?????k? ??? ]@A?8?]z?F | uQxk?? ?y?k|??l?R???g"MR??")?\?^3??^???e5;@an.??5?c:???CR????>?}P??>8n?Z?q+????5??L???C????{?K?V???8?r????S???` ????a??????8%?????????W?c??}w??z? ???+<??g?c>d?J4?wg|???i?Q1(??F??d??3k????tO,?xo$+g?"???.?^ ?O??U?`??w????$]???Po?8U?]??C?-??~????Y??hk94?,#?EM?#?!Q/,2P??0m???fQh]?z?n?iH5???X77???u?????`??<? (?6AW??v?`?2<&? ??jEC?3H?nfJ???m?????t???????(.??,?NC??0?4q??-{u Z?<[,Dm ?????uF??g???????p? fd ????4?M[?????b?v>???2k??n?K=7? >R?J???F?v$??????????j ?r???yRtt???B:T8?yA????\?3?F?}??2??xO??%???,?E?1?7h?c??GM?'??L???5ú?Z?DHEb???g?R??i??4???-?^????,???"A)???l:m?k? ???9 P_?S??$??B?? i?%??#??????????u?#`F? VuruI?.3??o(VmQEs?u?.?fO????@?)??r??gS? ??????>???(zW?????? ???????RSRNHx?jx??f&;X??J?????&;?r?"?4=?qC?>V'??]????o?8:??i?*????u&hj?????????????1]???|.4??k???#9???h???GG:?&??.?-?-7?u???Wy@1?^?AO???X?t???ja??"+Je ?v]?????L.??;+?? ?!??(2???R???_yE????s?{Z??3K[@?+????l?OO?" J???? ??[???pvx ?zO)"?/?w?????5??DGJT )s?u?ws4? ??[M8@?V{8???Sv%,?B?P1??o??g???????H?QIi?? ^???^?? N???n?3?v??????B??9?ZK??;??52A???S:/%}?]?ld??1K?f? ??Dq??~gH??o?ao??P??NU????9< ??k????%Cv?f?Xk<???? p7.??R?[?I9???Ba?0?<4S?&QnK?????L????6DF?|?7QLs?`#??oBG??m?y?3T????!?????b?b?????T ??LM?U???a??Y>??)???P??ye?HM?ffh\?Hd????~?????:qI?YE?W????j2?c??/????n??Ð???8_?Q6/??"ha?B*Z!????]K? ?jl E\?>RFO7n???*??G?????q K?(XH?Q????????2$???????V???#???> ???>(<???9>?Mt&?? 4-a+????e/?!???El?$?+T?8????????P?L=??_USh?0DEE?p^???????P<???I V?A?,??>? V}??P~z???8????5????nMwC??E?p?njJ0?^?h???js;c"[??"D??B???5Z?j8????R)n?p??w"??N}Vh????Bb??U?h??????N?E??+ W?@???7?Z??v?? t?FY?#4]3?U???y?m}e? S\? ???Y???1.?:z?#"q??$\??K????q?Ya ? ???P????d{???a?<%??c?/??^9???A?]:?4?3:?? 9"N??n?s??!????J??6???$?g???\ ?S{?U??$?<?p8?[????.;????E????03d? ?^?=? ??`? B?/3?Y?_?L+???%??{??X??????ce???wJH??/U?k???pj???_???EHM?L? ?K7?#@ h6/??g?M?N{?Dj???W? {f?L???\?ySP/?V?QY?C??????dD`????? ??_??e??[??}?:??rL?@?n???Nnc ????h?Q?????????"}?.S <?Y5???p?????K?q???/??? w =?,??u&???7 ????A0?? ?rM?;???X????#?v[??????c?y?W1?H!tD? }??>?N`?????^?!?'?%????R???f ?MK?Bwq??Ah???i??^???n\#?UI??u?MY??.??!I???)?H?SG@??? ?/??I#????gJ?DX wM?L0??#?w?p?U?L?&U??x????A^?r- N!?x&?e??j:?!????G1?(? ???.??$???k?8???? ?^^?%?[?Bt?.??mw??H?H3W????y?~???':q?{.????!?}?hLOx1????k?????? `S` ?????BVG?)???W`?6??7???,??. ?? ?L Quote Link to comment https://forums.phpfreaks.com/topic/264793-unable-to-insert-long-text-in-mysql-through-php/#findComment-1357033 Share on other sites More sharing options...
Barand Posted June 26, 2012 Share Posted June 26, 2012 could be that any quotes in there are causing the problem. before inserting, try $encrypted = addslashes($encrypted); Quote Link to comment https://forums.phpfreaks.com/topic/264793-unable-to-insert-long-text-in-mysql-through-php/#findComment-1357035 Share on other sites More sharing options...
shiza Posted June 26, 2012 Author Share Posted June 26, 2012 Thank You soo much...now it is inserted... But now it not remains the same value as it was.and i m unable to decrpyt it... Tell me any way to get this text again as it was before addslashes(); Because i have to do decrption now... Quote Link to comment https://forums.phpfreaks.com/topic/264793-unable-to-insert-long-text-in-mysql-through-php/#findComment-1357036 Share on other sites More sharing options...
Barand Posted June 26, 2012 Share Posted June 26, 2012 stripslashes() or if you still need the original, create a new var when adding slashes and insert that new var into database Quote Link to comment https://forums.phpfreaks.com/topic/264793-unable-to-insert-long-text-in-mysql-through-php/#findComment-1357037 Share on other sites More sharing options...
shiza Posted June 27, 2012 Author Share Posted June 27, 2012 $final=addslashes($encrypted); mysql_query("INSERT INTO voter(encrypt) VALUES('$final')",$con); Only var $final is stored in the DB.. after retrieving its value $data=stripslashes($final); But $data is not equal to $encrypted...How to get $encrypted's original value??? Quote Link to comment https://forums.phpfreaks.com/topic/264793-unable-to-insert-long-text-in-mysql-through-php/#findComment-1357340 Share on other sites More sharing options...
shiza Posted June 27, 2012 Author Share Posted June 27, 2012 If I use $final=mysql_real_escape_string($encrypted); mysql_query("INSERT INTO voter(encrypt) VALUES('$final')",$con); what can be the function to get $encrypted from $final???? $data=_____($final); Quote Link to comment https://forums.phpfreaks.com/topic/264793-unable-to-insert-long-text-in-mysql-through-php/#findComment-1357346 Share on other sites More sharing options...
xyph Posted June 27, 2012 Share Posted June 27, 2012 Lose the addslashes/stripslashes Try using base64_encode() before you submit the data, and base64_decode when you want to use it. Quote Link to comment https://forums.phpfreaks.com/topic/264793-unable-to-insert-long-text-in-mysql-through-php/#findComment-1357347 Share on other sites More sharing options...
shiza Posted June 27, 2012 Author Share Posted June 27, 2012 Thnx... base64_encode() and base64_decode() do what i want.... Problem Sloved... Thanks every1 for replying and helping me out... Quote Link to comment https://forums.phpfreaks.com/topic/264793-unable-to-insert-long-text-in-mysql-through-php/#findComment-1357388 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.