reGative Posted June 7, 2010 Report Share Posted June 7, 2010 Sveiki, Jau pus dienu cenšos izpīpēt, kāpēc man nesanāk uzrakstīt raksta update. index.php <?php // Datubāzes uzstādījumu iekļaušana lapā // include("includes/init.php"); // Lapas nosaukuma uzstādījums // $pagename = "Labot rakstus"; // Header iekļaušana lapā // include("style/head.php"); ?> <?php $result = mysql_query("SELECT * FROM zinas"); while($row = mysql_fetch_array($result)) { ?> <a href="edit.php?id=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a> <?php } if(isset($_GET['darbiiba']) and $_GET['darbiiba'] == "send") { $sql = "UPDATE zinas SET title='{$_POST['title']}' ievads='{$_POST['ievads']}' teksts='{$_POST['teksts']}' WHERE id='{$_POST['id']}')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Raksts iesniegts."; } ?> <?php $id = $_GET['id']; $lieta = mysql_query("SELECT * FROM zinas WHERE id='{$id}'") or die(mysql_error()); while($row = mysql_fetch_array($lieta)) {?> <form action="edit.php?darbiiba=send" method="post"> <input type="hidden" name="id" value="<?php echo $id; ?>" /> Virsraksts:<br /> <input type="text" name="title" value="<?php echo $row['title']; ?>"/><br /> Ievads (Līdz 500 simboliem):<br /> <textarea name="ievads" rows="4" cols="80"><?php echo $row['ievads'] ?></textarea><br /> Teksts:<br /> <textarea name="teksts" rows="5" cols="80"><?php echo $row['teksts']; ?></textarea><br /> <input type="submit" value="Iesniegt rakstu!" /> </form> <?php } ?> <?php // Footer iekļaušana lapā // include("style/foot.php"); ?> Es zinu, haoss. Bet tas netraucē. Bet kāpēc, kad vēlos labot tekstu, parādās 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 'ievads='Esmu atvēris paškodētu blogu.gg' teksts='' WHERE id='1')' at line 1? Manu prāt, skripts ir pareizs, bet tik un tā, nav kkas kārtībā... Quote Link to comment Share on other sites More sharing options...
briedis Posted June 7, 2010 Report Share Posted June 7, 2010 UPDATE table SET col1 = value, col2 = value, col3...... Quote Link to comment Share on other sites More sharing options...
reGative Posted June 7, 2010 Author Report Share Posted June 7, 2010 Bet kā man ir? Man jau ir pareizi. Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted June 7, 2010 Report Share Posted June 7, 2010 Tavs praats nav pareizs -> http://dev.mysql.com/doc/refman/5.0/en/update.html (pieveers uzmaniibu komatiem). Un es pie taviem topikiem jau 100 reizi rakstu - SQL injekcijas FTW... Quote Link to comment Share on other sites More sharing options...
briedis Posted June 7, 2010 Report Share Posted June 7, 2010 Un kodu vajag arī normāli tabulēt, lai ir kaut cik pārskatāmi, citādi šitā NAV OK! Stulbs attaisnojums - "Bet tas netraucē." Quote Link to comment Share on other sites More sharing options...
reGative Posted June 7, 2010 Author Report Share Posted June 7, 2010 (edited) Skaidrs... Rīt lasīšu padziļināti manuāli. $sql = "UPDATE zinas SET title='{$_POST['title']}' ievads='{$_POST['ievads']}' teksts='{$_POST['teksts']}' WHERE id='{$_POST['id']}')"; ... ir nepareizs skripts. $sql = "UPDATE zinas SET title='{$_POST['title']}', ievads='{$_POST['ievads']}', teksts='{$_POST['teksts']}' WHERE id='{$_POST['id']}'"; ... ir pareizs skripts. Paldies par palīdzību, tagad zināšu uz visiem laikiem. BTW - piekrītu rATRIJS'am, manas SQL injekcijas ir liels FTW! :D UPDATE : briedis - par to es arī pašlaik domāju to tūlīt izdarīt, pakārtot ar komentāriem, lai ir pārskatāmi. Edited June 7, 2010 by reGative Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted June 7, 2010 Report Share Posted June 7, 2010 btw kods ir jaaraksta sakaartots (un komenteets) uzreiz nevis peecaak jaapaarkaarto, jaasakomentee. Buus i mazaak kljuudu i vieglaak saprast visu. Quote Link to comment Share on other sites More sharing options...
reGative Posted June 7, 2010 Author Report Share Posted June 7, 2010 (edited) Starpcitu, man datubāze ir utf-8 general kodējumā, bet iesūtot kādu rakstu datubāzē, tāpat garumzīmju vietā ir kkādi smiboli nesaprotami. Vai pie, piem., $_POST['title'] ir kkas jāliek klāt kvērijā? Un pašā phpmyadminā collation ir utf-8 general Edited June 7, 2010 by reGative Quote Link to comment Share on other sites More sharing options...
Леший Posted June 7, 2010 Report Share Posted June 7, 2010 Tajā lapā, kur tev forma, charsetu arī uzliec utf8 Quote Link to comment Share on other sites More sharing options...
reGative Posted June 7, 2010 Author Report Share Posted June 7, 2010 Леший - taisni Notepad++, un tur defaultā uzlieku UTF-8 Without BOM Quote Link to comment Share on other sites More sharing options...
briedis Posted June 7, 2010 Report Share Posted June 7, 2010 Ir meta tags utf-8? Quote Link to comment Share on other sites More sharing options...
reGative Posted June 7, 2010 Author Report Share Posted June 7, 2010 briedis - protams, es nesāku veidot webu, ja nav uzrakstīts meta tags utf-8 Quote Link to comment Share on other sites More sharing options...
Леший Posted June 7, 2010 Report Share Posted June 7, 2010 SET NAMES UTF8 pēc konekcijas arī ir uzlikts? Quote Link to comment Share on other sites More sharing options...
reGative Posted June 7, 2010 Author Report Share Posted June 7, 2010 Леший - uzliku, bet tagad db ir kā pienākās - bet browserī ir ķeburi. :D labi, laikam db atstāšu, kā bija, tur nav ko. Quote Link to comment Share on other sites More sharing options...
Леший Posted June 7, 2010 Report Share Posted June 7, 2010 Ja browserī ir ķeburi, skaties meta charset. Teksti, kas ierakstīti bez SET NAMES, normāli nerādīsies 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.