CodeLobster IDE

Free cross-platform PHP IDE (HTML, PHP, CSS, JavaScript, Python code editor) with support Drupal, Joomla, Twig, JQuery, BackboneJS, LaravelJS, Node.js, CodeIgniter, CakePHP, Laravel, Magento, MeteorJS, Phalcon, Symfony, VueJS, WordPress, Yii
It is currently Thu Mar 28, 2024 12:04 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: why is tjis not updating
PostPosted: Tue Apr 04, 2023 9:51 pm 
Offline

Joined: Mon Apr 03, 2023 9:50 pm
Posts: 5
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);
?>


Top
 Profile  
 
 Post subject: Re: why is tjis not updating
PostPosted: Tue May 02, 2023 8:47 am 
Offline
Site Admin

Joined: Wed Sep 12, 2007 2:18 pm
Posts: 3931
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 58 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2016 phpBB Group