CodeLobster IDE
http://codelobster.com/forum/

why is tjis not updating
http://codelobster.com/forum/viewtopic.php?f=3&t=25233
Page 1 of 1

Author:  itsme [ Tue Apr 04, 2023 9:51 pm ]
Post subject:  why is tjis not updating

Quote:
This code is just to update the receiptno by adding 1 and displaying the value of receiptno.
The only prob, it does neither.?? says "updated but NOT


Code:
<?php
$link = mysqli_connect("localhost", "root", "", "homedb");
// Check connection
if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); }

$id = 'id';
$receiptno='';

/* Perform a query, check for error */
$sql = "UPDATE control SET
receiptno = '$receiptno' + 1 where id='$id'";
echo $receiptno;
if(mysqli_query($link, $sql)){ echo "updated"; }
else { echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); }
// Close connection
mysqli_close($link);
?>

Author:  Admin [ Tue May 02, 2023 8:47 am ]
Post subject:  Re: why is tjis not updating

Hi.

Here is the correct code:

Code:
$sql = "UPDATE control SET receiptno = receiptno + 1 where id='$id'";


(initially receiptno should be =0 in the database)

Regards,
Codelobster Team.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/