Undefined index:

1Tsme1941

Member
My goodness, here again. with I thought would be simple. Object is to add 1 to the
"receiptno" in the "numbers" table and print the receiptno. please tell me in lay
terms what is wrong.
----------------------------------
code:
<?php
$server = "localhost";
$user = "root";
$pass = "";
$db = "prerentdb";
$conn = mysqli_connect($server, $user, $pass, $db);
if(mysqli_connect_error())
{ echo "<p>crap..error.</p>"; echo "<p>Exiting...</p>"; exit(); }

$receiptno="receiptno";
echo "<center>";echo date('m/d/y');

echo "Receiptno ".$_POST["receiptno"].""; // print the receiptno

$receiptno = "receiptno+1";

$querySQL = "update numbers set receiptno='$receiptno'";
$res = $conn->query($querySQL);
if($res)
{ echo "<p>record updated.</p>"; }
else
{ echo "<p>error.</p>"; exit(); }
?>.
--------------------------------------
error:
Notice: Undefined index: receiptno on line 13
 

1Tsme1941

Member
My code does what I want except print the receiptno on the report.
I search but don't find example for this. Please
----------------------------------------------
the code:
<?php
$link = mysqli_connect("localhost", "root", "", "prerentdb");
// Check connection
if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); }
echo "<center>";echo date('m/d/y'); echo "<br />";
$id='id';
$receiptno = 'receiptno';
echo "$receiptno"; echo "<br />"; // prints "receiptno"
$sql = " UPDATE numberstbl
SET receiptno = receiptno + 1 where id=$id ";
if(mysqli_query($link, $sql)){ echo "receiptno was updated successfully."; }
else { echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); }

// Close connection
mysqli_close($link);
?>
 
Top