php - Mysql update statement won't execute -
can me this? when i'm trying update table nothing happens , can't figure out what's wrong. i've tried different query's not 1 worked.
my code: http://pastebin.com/8zdpm0ah doesn't work line 23
<?php foreach($db->query("select * blog id '$id'") $row){ echo "titel: <input type='text' size='50' name='titel' value='$row[titel]'><br>"; echo "post:<br>"; echo "<textarea name='editblog'>"; echo $row[post]; echo "</textarea>"; echo "<input type='hidden' name='id' value='"; echo $row[id]; echo "'>"; } ?> <input type="submit" value="edit post" name="postedit"> </form> <script> ckeditor.replace( 'editblog' ); </script> <?php if(isset($_post['postedit'])){ $titel = $_post['titel']; $post = $_post['editblog']; $id = $_post['id']; $sth = $db->prepare("update blog set titel='$titel',post='$post' id=$id"); $sth->execute(); echo "<h2>post edited!</h2>"; }
if aren't using prepared statements intended (using $db->bind_params()
), recommend switching line 29
$sth = $db->query("update blog set titel='$titel',post='$post' id=$id");
and removing line 30.
Comments
Post a Comment