CodeLobster IDE http://codelobster.com/forum/ |
|
how to define variables as numeric http://codelobster.com/forum/viewtopic.php?f=3&t=25155 |
Page 1 of 1 |
Author: | 12Strings [ Thu Aug 04, 2022 11:12 pm ] |
Post subject: | how to define variables as numeric |
Quote: Hi, I have some issues with my code. It's to refresh account payfile at end of month. Comments are noted in code (//). #1) how to define variables as numeric(I've tried several examples(forums and manuals) #2) how to add several variables together so they are known as numeric(they are all decimal 8,2 in the database) #3) Please, someone explain the "Undefined variable: mysql". Code: <?php //Open a new connection to the MySQL server = mysqli_connect("localhost", "root", "", "prerentdb"); // Check connection if( === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } //MySqli Select Query = "select * FROM payfile"; echo "<center>";echo date('m/d/y');echo "<br />"; =0; ="prevbal"; ="latechg"; ="secdep"; ="damage"; ="courtcost"; ="nsf"; ="amtdue"; ="amtpaid"; ="paidsum"; = + + + + + ; // Warning: A non-numeric value encountered x 5 line 21 = + ; Warning: // A non-numeric value encountered x 1 line 22 // if no payment or partial payment, add $10 to latechg field and amount not paid to prevbal field if ( < ) // Notice: Undefined variable: amtpaid { = + 10; = - ; } // if payment = amtdue clear due if ( == ) // Notice: Undefined variable: amtpaid { = 0; = 0; } // if over-payment subtract over-payment // from prevbal field if ( > ) // Notice: Undefined variable: amtpaid { = - ; = 0; = 0; } = 0; = 0; = 0; = 0; // refresh every record - give every record the below values = '0.00'; = '0.00'; = ' '; = '0.00'; = ' '; // Perform a query, check for error if (! -> query("UPDATE payfile SET // Undefined variable: mysqli Fatal error: Uncaught Error: Call to a member function query() on null prevbal='',latechg='', hudpay='', amtpaid='', datepaid='', comment='', paidsum='' where unit = ")); mysqli_query() or die(mysql_error()); ?> Quote: these are error messages:
Warning: A non-numeric value encountered in C: mpp\htdocs\property efreshpayments.php on line 21 Warning: A non-numeric value encountered in C: mpp\htdocs\property efreshpayments.php on line 21 Warning: A non-numeric value encountered in C: mpp\htdocs\property efreshpayments.php on line 21 Warning: A non-numeric value encountered in C: mpp\htdocs\property efreshpayments.php on line 21 Warning: A non-numeric value encountered in C: mpp\htdocs\property efreshpayments.php on line 21 Warning: A non-numeric value encountered in C: mpp\htdocs\property efreshpayments.php on line 21 Warning: A non-numeric value encountered in C: mpp\htdocs\property efreshpayments.php on line 22 Notice: Undefined variable: ampaid in C: mpp\htdocs\property efreshpayments.php on line 32 Notice: Undefined variable: mysqli in C: mpp\htdocs\property efreshpayments.php on line 44 Fatal error: Uncaught Error: Call to a member function query() on null on line 44 |
Author: | Admin [ Fri Aug 05, 2022 7:38 am ] |
Post subject: | Re: how to define variables as numeric |
Hi. 1) $x = 24535; var_dump(is_numeric($x)); 2) If You want to get a sum then $num1 = "12.5"; $num2 = "15.5"; $result = floatval($num1) + floatval($num2); If You want to store 2 values then You should create an array $array = array(); $array[] = $num1; $array[] = $num2; 3) There is some truncated code here. Here is the sample of correct code: $con = mysqli_connect("localhost","root","","prerentdb"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); exit(); } $con->query("select * FROM payfile"); Regards, Codelobster Team. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |