Hi itsme again. I have this prob I can’t get past. This is a program to pay a fee and print a receipt.
I enter the unit and payment into a form and get the message:
Parse error: syntax error, unexpected ‘’; ’ (T_CONSTANT_ENCAPSED_STRING) on line 62.
Please advise. Thanks!
You didn’t exit out of PHP before going back into HTML several times. You are also missing a quote. These are the most simplest mistakes you would not be having if you used a proper editor or IDE. You are also using deprecated HTML.
Of course, you can’t do that because they’re not numbers, unless your initial value assignments would normally have actual numbers in them. You can concatenate the strings together using ., but that doesn’t make a lot of sense.
Perhaps the only reason you’ve stopped getting “Not numeric” errors is because of the parse error.
Hi, thanks for helping me. I still must address the “non-numeric” issue and I ask for help again.
Am I not adding the fields correctly? all these are in the database as decimal (8,2). Should they
be otherwise? My first attempt at parameterized statements - not so good. I searched for but didn’t
find definition for “double” or “float”; used “d” for my decimal fields? Help?
My revised code follows:
<!DOCTYPE html><html>
<body><center>
<img src="apt-pic.jpg" alt="apartment" height=75 width=200><br>
<?php
echo date('m/d/y');echo "</br>";
?>
For:<SELECT name="options">
<option value="#990033" style="background-color: Violet;">Rent payment</option>
<option value="#003300" style="background-color: Aquamarine;">Background Check</option>
<option value="#6600cc" style="background-color: Pink;">Security Deposit Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Damages Payment</option>
<option value="#990033" style="background-color: Violet;">Late Charges Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Court Costs Payment</option>
<option value="#6600cc" style="background-color: Pink;">NSF Payment</option>
<option value="#990033" style="background-color: Violet;"> </option>
</SELECT><br>
<input type="text" size = 50 STYLE="color: #000000; background-color: #D4AAFF;" name="Name" value="Business Name"><br>
<input type="text" size = 50 STYLE="color: #000000; background-color: #D4D4FF;" name="Addy1" value="Business address"><br>
<input type="text" size = 50 STYLE="color: #000000; background-color: #D4AAFF;" name="Addy2" value="City, State, Zip"><br>
<?php
$link = mysqli_connect("localhost", "root", "", "prerentdb");
// Check connection
if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); }
$unit = $_POST['unit'];
$amtpaid = $_POST['amtpaid'];
$amtdue = 'amtdue';
$datepaid = $_POST['datepaid'];
$hudpay = 'hudpay';
$prevbal='prevbal';
$latechg='latechg';
$secdep='secdep';
$damage='damage';
$courtcost='courtcost';
$nsf='nsf';
$paidsum='paidsum';
$comments='comments';
$receiptno='receiptno';
$id='id';
$due='due';
// Attempt select query execution
$result = mysqli_query($link,"SELECT * FROM payfile");
$row= mysqli_fetch_array($result);
?>
<b> tenant paying is: <?php echo $_POST["unit"]; ?> -
Amount paid is: <?php echo $_POST["amtpaid"]; ?><br>
<input type="text" size = 75 STYLE="color: #000000; background-color: #D4AAFF;" name="sign" value="Sign here">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="thanks" value="We Thank You"><br>
<?php
$due = $prevbal + $latechg + $secdep + $damage + $courtcost + $nsf; // line 52
$due = $due + $amtdue; $amtpaid = $paidsum; // line 53
/* if no payment or partial payment, add $10 to latechg field and amount not paid to prevbal field */
if ($amtpaid < $due)
{ $latechg = $latechg + 10; $prevbal = $due - $amtpaid; }
/* if payment = amtdue clear due */
if ($amtpaid == $due)
{ $prevbal = $latechg = $secdep = $damage = $courtcost = $nsf = 0; }
/* if over-payment subtract over-payment from prevbal field */
if ($amtpaid > $due )
{ $prevbal = $due - $amtpaid; $latechg = $secdep = $damage = $courtcost = $nsf = 0; }
// Perform a query, check for error
$sql = "UPDATE payfile SET
amtpaid=?, prevbal=?, latechg=?, secdep=?, damage=?, courtcost=?,
nsf=?, hudpay=?, datepaid=?, paidsum=?, comments=? Where unit = ?";
//bind parameters for markers, where (s = string, i = integer, d = double, b = blob)
$results = $statement->bind_param('ddddddddsdsi', $amtpaid, $prevbal, $latechg, $secdep, $damage, $courtcost,
$nsf, $hudpay, $datepaid, $paidsum, $comments, $unit); // line 69
if($results){ print 'Success! record updated'; }
else{ print 'Error : ('. $mysqli->errno .') '. $mysqli->error; }
?>
</b></center></body></html>
error messages:
Warning: A non-numeric value encountered in C:\xampp\htdocs\property\payment.php on line 52
Warning: A non-numeric value encountered in C:\xampp\htdocs\property\payment.php on line 52
Warning: A non-numeric value encountered in C:\xampp\htdocs\property\payment.php on line 52
Warning: A non-numeric value encountered in C:\xampp\htdocs\property\payment.php on line 52
Warning: A non-numeric value encountered in C:\xampp\htdocs\property\payment.php on line 52
Warning: A non-numeric value encountered in C:\xampp\htdocs\property\payment.php on line 52
Warning: A non-numeric value encountered in C:\xampp\htdocs\property\payment.php on line 53
Notice: Undefined variable: statement in C:\xampp\htdocs\property\payment.php on line 69
Fatal error: Uncaught Error: Call to a member function bind_param() on null :69
Stack trace: #0 {main} thrown in C:\ line 69
You set all the variables to contain strings. You can’t add a string to a string because, well, what happens in normal maths if you want to add “Bill” to “Dave”? Nothing, because they’re not numbers. Some languages (VB, for example) allow the “+” symbol to be used either to add numbers, or to concatenate strings (I believe it’s known as “Polymorphism”), but PHP does not. So when you try to add one string to another using a mathematical symbol, you’ll get “Not a Number” errors.
I suspect the assignment lines that I quoted above are the issue. What do you think those lines are doing, or more to the point what do you want them to do?