Faks Posted March 21, 2011 Report Share Posted March 21, 2011 (edited) Nu tad Labvakar Dāmas un Kungi lieta tāda ka man ir problēmas ar mysql edit :D kā sakās mūžu dzivo mūžu mācies ironija tami ka ar mysql (insert,delete) tiku gala iestudēts bet ar mysql update ir vienas problēmas bet nu atpakaļ pie problēmas šeit ir pats kods kuru izmantoju Pats kods if ($_GET['comment'] == 'edit') { $comment_id_edit = (INT)$_GET['id_edit']; $select_comment_edit = mysql_query("SELECT hosting_comment_text,hosting_comment_id FROM hosting_comment WHERE hosting_comment_id = '".$comment_id_edit."' ") or die (mysql_error()); $comment_edit = mysql_fetch_array($select_comment_edit); $edit_comment_text = $comment_edit['hosting_comment_text']; mysql_query("UPDATE hosting_comment SET hosting_comment_text = '".$edit_comment_text."' WHERE hosting_comment_id = '".$comment_id_edit."' ") or die (mysql_error()); echo "<form id='form1' name='form1' method='post'> <p> <textarea name='comment_text' cols='50' rows='10' id='textarea' value='$edit_comment_text' >$edit_comment_text </textarea> <input type='hidden' name='token' value='{$token}'/> <p> <input type='submit' name='Submit' id='button' value='{$lang['BODY_NEWS_COMMENT_SUBMIT']}' /> <input type='reset' name='Reset' id='button' value='{$lang['BODY_NEWS_COMMENT_RESET']}' /> </p> </form>"; } Nevaru īsti saprast kamī problēma varbūt kādam galva gaišāka par manu :D ! Mājas lapa http://hostings.flush.ws/ pārbaudīt var pie jaunumu sadaļas komentāriem ! lietotajs guest kods guest11 | Lūdzams nespamot visur kur vien prātā ienāk ! Edited March 21, 2011 by Faks Link to comment Share on other sites More sharing options...
briedis Posted March 21, 2011 Report Share Posted March 21, 2011 Kur īsti ir problēma? Kas neJiet? Ir kādi kļūdu paziņojumi? Link to comment Share on other sites More sharing options...
Faks Posted March 21, 2011 Author Report Share Posted March 21, 2011 (edited) Kur īsti ir problēma? Kas neJiet? Ir kādi kļūdu paziņojumi? nau tur jau tas joks ka nau un rokas vel aug no pareizas vietas :) Edited March 21, 2011 by Faks Link to comment Share on other sites More sharing options...
briedis Posted March 21, 2011 Report Share Posted March 21, 2011 Kur ir formai action atribūts? Kur tiek uzstādīts šis mainīgais? $_GET['comment'] Link to comment Share on other sites More sharing options...
Faks Posted March 21, 2011 Author Report Share Posted March 21, 2011 Kur ir formai action atribūts? Kur tiek uzstādīts šis mainīgais? $_GET['comment'] echo "<a href='/?section=nwcomment&id=".$id."&comment=edit&id_edit=".$row_news_comment['hosting_comment_id']."'>Edit Comment</a>"; vis ir pareizi :) Link to comment Share on other sites More sharing options...
briedis Posted March 21, 2011 Report Share Posted March 21, 2011 Salabo identāciju, kods ir nepārskatāms. Link to comment Share on other sites More sharing options...
Faks Posted March 21, 2011 Author Report Share Posted March 21, 2011 Salabo identāciju, kods ir nepārskatāms. emm negluzi tevi sapratu bet vis ir pareizi ! Link to comment Share on other sites More sharing options...
xPtv45z Posted March 21, 2011 Report Share Posted March 21, 2011 Par to pareizo roku augšanas vietu gan vēlreiz padomā. Tev tur kodā vispār nekādas loģikas nav. Tu izvelc par komentāru datus un pirms tos dod lietotājam labot, jau izpildi UPDATE ar vecajiem datiem. Jo tas ko tu tagad iepostoji ir, tas, kas notiek, kad nospiež uz linka, bet kur ir darbība, kad būs nospiests submit formā? Link to comment Share on other sites More sharing options...
codez Posted March 21, 2011 Report Share Posted March 21, 2011 beidz ākstīties un datus, kuri kaut ko maina aiz autorizācijas, nosūtīt ar $_GET. Tie jāsūta ar $_POST Link to comment Share on other sites More sharing options...
Faks Posted March 21, 2011 Author Report Share Posted March 21, 2011 (edited) nenu diskusijas var vienmēr vest kā noprotu neviens pat piemeru nevar uzcept lai cilvēks var iebraukt :D kā novest mysql update līdz ejošai stadijai :D pats kods pilnāks izgriezu lieko lai netraucētu ! $comment = mysql_query("SELECT hosting_comment_id,hosting_comment_news_id,hosting_comment_text,hosting_comment_nick,hosting_comment_date FROM hosting_comment WHERE hosting_comment_news_id = '$id' "."limit $offset, $comment_limit") or die(mysql_error()); if (mysql_num_rows($comment) != 0) { while ($row_news_comment = mysql_fetch_array($comment)) { echo "$row_news_comment[hosting_comment_nick] $row_news_comment[hosting_comment_date] "; if ($_SESSION['permission'] >= 2) { echo "<a href='/?section=nwcomment&id=".$id."&comment=edit&id_edit=".$row_news_comment['hosting_comment_id']."'>Edit Comment</a>"." "."<a href='/?section=nwcomment&id=".$id."&comment=delete&id_delete=".$row_news_comment['hosting_comment_id']."'>Delete Comment</a>"; if ($_GET['comment'] == 'edit') { $comment_id_edit = (INT)$_GET['id_edit']; $select_comment_edit = mysql_query("SELECT hosting_comment_text,hosting_comment_id FROM hosting_comment WHERE hosting_comment_id = '".$comment_id_edit."' ") or die (mysql_error()); $comment_edit = mysql_fetch_array($select_comment_edit); $edit_comment_text = $comment_edit['hosting_comment_text']; mysql_query("UPDATE hosting_comment SET hosting_comment_text = '".$edit_comment_text."' WHERE hosting_comment_id = '".$comment_id_edit."' ") or die (mysql_error()); echo "<form id='form1' name='form1' method='post'> <p> <textarea name='$edit_comment_text' cols='50' rows='10' id='textarea' value='$edit_comment_text' >$edit_comment_text </textarea> <input type='hidden' name='token' value='{$token}'/> <p> <input type='submit' name='Submit' id='button' value='{$lang['BODY_NEWS_COMMENT_SUBMIT']}' /> <input type='reset' name='Reset' id='button' value='{$lang['BODY_NEWS_COMMENT_RESET']}' /> </p> </form>"; } if ($_GET['comment'] == 'delete') { $comment_id_delete = (INT)$_GET['id_delete']; mysql_query("DELETE FROM hosting_comment WHERE hosting_comment_id = '".$comment_id_delete."' ") or die (mysql_error()); echo "<meta http-equiv='REFRESH' content='0'/>"; } } echo "<br> $row_news_comment[hosting_comment_text] <br>"; } } Edited March 21, 2011 by Faks Link to comment Share on other sites More sharing options...
mounkuls Posted March 21, 2011 Report Share Posted March 21, 2011 <form id='form1' name='form1' method='post'> Uz kurieni to method post tā forma lai sūta bez action? briedis taču uzrakstija jau... $select_comment_edit = mysql_query("SELECT hosting_comment_text,hosting_comment_id FROM hosting_comment WHERE hosting_comment_id = '".$comment_id_edit."' ") Kāda jēga selektēt laukā to ,ko jau tā pat zini? Tas par hosting_comment_id. Link to comment Share on other sites More sharing options...
Kemito Posted March 21, 2011 Report Share Posted March 21, 2011 Priekš IE versijas noderētu norādīt ... action="this_is_my_link" Formā protams. Link to comment Share on other sites More sharing options...
Faks Posted March 21, 2011 Author Report Share Posted March 21, 2011 (edited) Priekš IE versijas noderētu norādīt ... action="this_is_my_link" Formā protams. to protams itka zinu jau uztaisiju bet tagad automatiski nak ieksa blanka pie edit :D protams ari pamainiju kodu pacik nau vajadzības taisīt divreiz vienu un topāšu select kā jau teica :) augstāk iznak tagad jau faktiski strādā bet automatiski pie edit ieliek blanku tuksu info :D kaut kāda pasaka :D { $comment_id_edit = (INT)$_GET['id_edit']; $edit_comment_text = $_POST['hosting_comment_text']; mysql_query("UPDATE hosting_comment SET hosting_comment_text = '".$edit_comment_text."' WHERE hosting_comment_id = '".$comment_id_edit."' ") or die (mysql_error()); echo "<form action='/?section=nwcomment&id=".$id."&comment=edit&id_edit=".$comment_id_edit."'' id='edit_comment' name='edit_comment' method='post'> <p> <textarea name='comment_text' cols='50' rows='10' id='textarea' value='$edit_comment_text' >$comment_text</textarea> <p> <input type='submit' name='Submit' id='button' value='{$lang['BODY_NEWS_COMMENT_SUBMIT']}' /> <input type='reset' name='Reset' id='button' value='{$lang['BODY_NEWS_COMMENT_RESET']}' /> </p> </form>"; } Edited March 21, 2011 by Faks Link to comment Share on other sites More sharing options...
mounkuls Posted March 21, 2011 Report Share Posted March 21, 2011 (edited) <textarea name='comment_text' cols='50' rows='10' id='textarea' value='$edit_comment_text' >$comment_text</textarea> un mēģini saņemt $edit_comment_text = $_POST['hosting_comment_text']; Uzmanīgākam jābūt. Un vēl if(issset($_POST['hosting_comment_text'])){ MySQL UPDATE query;} else { darīt ko citu un; } //tālāk jau drukā laukā formu. Savādāk tur notiks UPDATE arī tad, ja neko tajā textarea neieraksta un ierakstīs bāzē tukšumu, tā teikt izdzēsīsi vēl to pašu, kas vēl bija. Edited March 21, 2011 by mounkuls Link to comment Share on other sites More sharing options...
Faks Posted March 21, 2011 Author Report Share Posted March 21, 2011 <textarea name='comment_text' cols='50' rows='10' id='textarea' value='$edit_comment_text' >$comment_text</textarea> un mēģini saņemt $edit_comment_text = $_POST['hosting_comment_text']; Uzmanīgākam jābūt. Un vēl if(issset($_POST['hosting_comment_text'])){ MySQL UPDATE query;} else { darīt ko citu un; } //tālāk jau drukā laukā formu. Savādāk tur notiks UPDATE arī tad, ja neko tajā textarea neieraksta un ierakstīs bāzē tukšumu, tā teikt izdzēsīsi vēl to pašu, kas vēl bija. paldies par ideju itkā darbojas bet tagad uzradās abnormāls gļuks :D ! uzrokas viena liekā forma ar neko a zem viņas labojama ! Link to comment Share on other sites More sharing options...
Recommended Posts