reGative Posted May 4, 2010 Report Share Posted May 4, 2010 (edited) Esmu uzrakstījis skriptu, kas rediģē rakstus. <?php $result = mysql_query("SELECT * FROM zinjas ORDER BY datums DESC"); while($row = mysql_fetch_array($result)) { echo '<p class="title"><a href="settings.php?id='.$row['id'].'">"' . $row['virsraksts'] . '"</a></p><br />';} $id = $_GET['id']; if(isset($_GET['edit']) and $_GET['edit'] == "$id") { mysql_query("UPDATE zinjas SET virsraksts = '$_POST[virsraksts]', ievads = '$_POST[ievads]', teksts = '$_POST[teksts]' WHERE id ='$id'"); } $id = $_GET['id']; $lieta = mysql_query("SELECT * FROM zinjas WHERE id='$id'") or die(mysql_error()); while($row = mysql_fetch_array($lieta)) { ?> <form method="post" action="settings.php?edit=<?php echo $_GET['id'];?>"> <input type="text" name="virsraksts" value="<?php echo $row['virsraksts']; ?>"/><br /> <textarea rows="7" cols="40" name="ievads"><?php echo $row['ievads']; ?></textarea><br /> <textarea rows="7" cols="40" name="teksts"><?php echo $row['teksts']; ?></textarea><br /> <input type="submit" value="Gatavs!" /></form> <?php } mysql_close($con);?> Bet, kāpēc nestrādā šis skripts? Ja vēlos rakstu labot, tad nekas nenotiek. Ja nav pareizi, tad nobīdiet mani uz pareizo pusi, Lūdzu! :) Edited May 4, 2010 by reGative Quote Link to comment Share on other sites More sharing options...
waplet Posted May 4, 2010 Report Share Posted May 4, 2010 (edited) debuggo :D if(isset($_GET['edit']) and $_GET['edit'] == "$id") bezjēdzīgi + nekādas aizsardzības. mysql_query("UPDATE zinjas SET virsraksts = {$_POST['virsraksts']}, ievads = {$_POST['ievads']}, teksts = {$_POST['teksts']} WHERE id = $id"); Salienc print'us un skaties, kura vieta izpildas un kura nē,.. + aiz update pieliec or die(mysql_error()); Edited May 4, 2010 by waplet Quote Link to comment Share on other sites More sharing options...
reGative Posted May 4, 2010 Author Report Share Posted May 4, 2010 (edited) Vai tiešām neviens nevar man palīdzēt? Saprotiet, ka caur DB labot nav iespējams, jo tur rāās ķeburi visādi, ne burti. It kā ir UTF-8 atbalsts ieslēgts, bet šim p**u*, tāpēc jāuzraksta skripts, kas labo saturu internet pārlūkā. Edited May 4, 2010 by reGative Quote Link to comment Share on other sites More sharing options...
reGative Posted May 4, 2010 Author Report Share Posted May 4, 2010 Un ja var, tad kā phpMyAdmin var uzlikt UTF-8, lai tur tekstam nerādās ķeburi, bet gan burti? Quote Link to comment Share on other sites More sharing options...
daGrevis Posted May 4, 2010 Report Share Posted May 4, 2010 Ar karotīti mutē?? =/ Quote Link to comment Share on other sites More sharing options...
waplet Posted May 4, 2010 Report Share Posted May 4, 2010 pēc konekcijas izveides uztaisi kvēriju mysql_query("SET NAMES utf8 COLLATION utf8_general_ci"); Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted May 4, 2010 Report Share Posted May 4, 2010 (edited) Ar karotīti mutē?? =/ kaa uzlikt PHPMYAdmin utf-8 1. Sakam ar to, ka dodamies uz 1 klasiiti un iemacamies lasiit. Kad shamais abguuts, tad megjinam palaist PHPMyAdmin 2. kad arii tas veiksmigi pabeikts, tad pielietojam punkta nr1. ieguutas iemanjas punktu Nr1 iemanjas pielietot tik ilgi kamer izdodas izburtot sekojoshu teikumu 'MySQL connection collation:' 3. izvelamies nepiecamo opciju, saglabajam izmainjas --- Edited May 4, 2010 by Grey_Wolf Quote Link to comment Share on other sites More sharing options...
reGative Posted May 4, 2010 Author Report Share Posted May 4, 2010 Paldies, es esmu iemācījies jau lasīt, kā redzi... Ehhhh...... Pffff...... Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted May 4, 2010 Report Share Posted May 4, 2010 Paldies, es esmu iemācījies jau lasīt, kā redzi... Ehhhh...... Pffff...... Nu tad droshi kjeries pie nakamajiem punktiem .... Quote Link to comment Share on other sites More sharing options...
bobsters Posted May 5, 2010 Report Share Posted May 5, 2010 debuggo :D if(isset($_GET['edit']) and $_GET['edit'] == "$id") wapletam tiesa! $_GET['edit'] == "$id" $_GET['edit'] nekad nebus vienads ar kaut kadu skaitli ja nonemsi $_GET['edit'] =="$id" tad vajadzetu taka stradat Quote Link to comment Share on other sites More sharing options...
indoom Posted May 5, 2010 Report Share Posted May 5, 2010 drīzāk tāpēc, ka formai action ir tikai uz edit, un tāds id vairs nepastāv. Vajag ieslēgt kļūdu paziņojumus, tad arī pamanītu, ka $_GET['id'] neeksistē pie posta. (kā arī pārējās kļūdas) Kā arī visiem posta datiem saliec mysql_real_escape_string() Un vēl, gan jau, ka formas actionā pie edit gribi likt $row['id'], nevis $_GET['id'] Pārējā pārāk neiedziļinājos. Quote Link to comment 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.