CodeLobster IDE http://codelobster.com/forum/ |
|
need help updating database http://codelobster.com/forum/viewtopic.php?f=3&t=24759 |
Page 1 of 1 |
Author: | 12Strings [ Wed Mar 18, 2020 3:05 am ] |
Post subject: | need help updating database |
I'm trying to update a couple of rows in a database using the form below and the php following: the form: <!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8"> <title>update Record Form</title> </head> <body><center> <font size=+2><b> update visits & lastused information database</font><br> <form action="crud-update.php" method="post"> <p><label for="target">target:</label> <input type="text" name="target" id="target"></p> <input type="submit" name="submit" value="Submit"> </form></body></html> -------------------------------------------------------------------------------------------- crud-update.php code: <?php require 'homedb-connect.php'; $target = $_POST["target"]; $visits = visits; $Lastused = Lastused; $sql = "UPDATE receiptno SET visits=visits+1, lastused=NOW() WHERE target=$target"; if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . $conn->error; } $conn->close(); ?> ----------------------------------------------------------------------------------------------- This is result. what's wrong? |
Author: | Admin [ Tue Mar 24, 2020 2:29 pm ] |
Post subject: | Re: need help updating database |
Hi. Please, try to add quotes to $target Code: = "UPDATE receiptno SET visits=visits+1, lastused=NOW() WHERE target='".."'"; Regards, Codelobster Team. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |