Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Generic User Avatar

not updating


  • Please log in to reply
1 reply to this topic

#1 guitarzRwe

guitarzRwe

  •  Avatar image
  • Members
  • 6 posts
  • OFFLINE
  •  
  • Local time:01:56 AM

Posted 04 April 2023 - 04:46 PM

 

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

 

<?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); 
?>

Edited by hamluis, 04 April 2023 - 05:53 PM.
Moved from Web Development to Programming - Hamluis.


BC AdBot (Login to Remove)

 


#2 xBlueRobot

xBlueRobot

  •  Avatar image
  • BSOD Kernel Dump Expert
  • 408 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:%systemroot%
  • Local time:06:56 AM

Posted 10 April 2023 - 08:19 AM

You're setting $id to 'id' and $receiptno to an empty string, unless you have a record which has an id of 'id' then SQL query isn't going to update anything at all.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users