Diana Madeira Posted April 14, 2017 at 10:31 PM Report #603633 Posted April 14, 2017 at 10:31 PM Olá tenho o seguinte código: <?php $_SESSION['message'] =''; include("config.php"); if($_SERVER['REQUEST_METHOD'] == 'POST') { if(isset($_POST["send"])){ $ISBN =$conn->real_escape_string($_POST['ISBN']); $Authorsname=$conn ->real_escape_string($_POST['Authorsname']); $Title= $conn ->real_escape_string($_POST['Title']); $edition= $conn ->real_escape_string($_POST['edition']); $year= $conn->real_escape_string($_POST['year']); $publisher= $conn->real_escape_string($_POST['publisher']); $category=$conn->real_escape_string($_POST['category']); $quantityinstock=$conn->real_escape_string($_POST['quantityinstock']); $price= $conn->real_escape_string($_POST['price']); } $sql= "UPDATE SET books (ISBN, Authorsname, Title, edition, year, category, publisher, quantityinstock, price) VALUES(".$ISBN.",'".$Authorsname."', '".$Title."', ".$edition.", ".$year.", '".$category."', '".$publisher."', ".$quantityinstock.",".$price.")"; if($conn->query($sql)===TRUE) { echo '<h3><font color="red">You have successfully updated </font></h3>'; } else { echo 'Error'; echo $sql; } } ?> Ao correr da-me o seguinte erro: Citação #1064 - 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 'SET books (ISBN, Authorsname, Title, edition, year, category, publisher, quantit' at line 1 Alguma ideia como resolver isto?
HappyHippyHippo Posted April 15, 2017 at 12:06 AM Report #603634 Posted April 15, 2017 at 12:06 AM em que tabela estás a fazer a actualização ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
RicardoSantos97 Posted April 16, 2017 at 11:55 AM Report #603645 Posted April 16, 2017 at 11:55 AM Estas a utilizar uma sintaxe incorrecta na query que pretendes realizar, consulta o seguinte link: https://dev.mysql.com/doc/refman/5.7/en/update.html Coloca também uma restrição aos registos que pretendes fazer o update, clausula where, caso contrario todos os registos vão sofrer alterações. 1 Report
bruno1234 Posted April 16, 2017 at 12:00 PM Report #603646 Posted April 16, 2017 at 12:00 PM Podes também dar um olhada nisto: http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now