database - post not completely posted PHP -
i have select value 'post', when wants change status of post unsolved solved have choose post en click 'change solved'
the problem when click on button, doesn't change because php takes not whole title of post. when post called 'photoshop crashes', sends 'photoshop'. that's why doesn't update in database, query can't find right post, when title of post 1 word, table gets updated.
<?php if (isset($_post['btnsolved'])) { // wanneer er op de knop geklikt proberen user te saven in de databank if (!empty($_post['btnsolved'])) { $solved = $_post['unsolved']; $conn = new mysqli("localhost","root","root","phpproject"); if ($conn -> connect_errno) { throw new exception("no connection database!"); } else { $sql = "update posts set status = 'solved' post='".$solved."'"; } } $conn->query($sql); } ?>
in body:
<h3>change status</h3> <form action="<?php echo $_server['php_self'];?>" method="post"> <?php if(mysqli_num_rows($showbugs) > 0) { echo "<select name= unsolved>"; while ($row = mysqli_fetch_assoc($showbugs)) { echo "<option value=" . $row['subject'] . ">" . $row['subject'] . "</option>"; } echo "</select>"; } ?> <br /> <input class="btn btn-info dropdown-toggle" type="submit" name="btnsolved" value="change solved" /> </form>
this when print of $sql
update posts set status = 'solved' post='photoshop'
does know why php can post 1 word, not whole title? might stupid, don't know how fix this.
try enclosing value in single quotes,
echo "<option value='" . $row['subject'] . "'>" . $row['subject'] . "</option>";
Comments
Post a Comment