Hi, can someone advise me as to why I get this error? thanks the code: <html> <head></head><body><center> <div class="display print"> <?php //Open a new connection to the MySQL server $link = mysqli_connect("localhost", "root", "", "homedb"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } echo date('m/d/y'); //MySqli Select Query $sql = "select * FROM paytbl"; $result = mysqli_query($link,$sql); if (!$result) { printf("Error: %s\n", mysqli_error($link)); exit(); }else{ while($row = mysqli_fetch_array($result)){ //Set at what record to break at 25 records per page $BreakAT=25; $pagenum = 0; echo date('m/d/y'); ?> <b> <div class="title"><h3>Payment Report</h3></div><br /> <table align="center" cellspacing=5 cellpadding=5 border=2> <thead> <tr> <th colspan=2> </th> <th bgcolor="cyan" colspan=2>Rent</th> <th bgcolor="99FF99">Prev</th> <th bgcolor="FF99FF">late</th> <th bgcolor="99FF99">sec</th> <th></th> <th bgcolor="99FF99">court</th> <th></th> <th bgcolor="99FF99">hud</th> <th>Date</th> <th colspan=2></th> <tr> <th>Tenant</th> <th>Unit</th> <th bgcolor="cyan">Due</th> <th bgcolor="cyan">Paid</th> <th bgcolor="99FF99">Bal</th> <th bgcolor="FF99FF">chg</th> <th bgcolor="99FF99">dep</th> <th bgcolor="FF99FF">damage</th> <th bgcolor="99FF99">cost</th> <th bgcolor="FF99FF">nsf</th> <th bgcolor="99FF99">pay</th> <th>Paid</th> <th bgcolor="cyan">Paidsum</th> <th>Comments</th> </tr> </thead> <?php $slice= array_slice($results,((($pagenum + 1) * $BreakAT) - $BreakAT), (($pagenum + 1)* $BreakAT)); foreach($slice as $row){ echo ' <tr> <td>' . $row['tenant'] . '</td> <td>' . $row['unit'] . '</td> <td align=right class="currency">$'.number_format($row['amtdue'],2).'</td> <td align=right class="currency">$'.number_format($row['amtpaid'],2).'</td> <td align=right class="currency">$'.number_format($row['prevbal'],2).'</td> <td align=right class="currency">$'.number_format($row['latechg'],2).'</td> <td align=right class="currency">$'.number_format($row['secdep'],2).'</td> <td align=right class="currency">$'.number_format($row['damage'],2).'</td> <td align=right class="currency">$'.number_format($row['courtcost'],2).'</td> <td align=right class="currency">$'.number_format($row['nsf'],2).'</td> <td align=right class="currency">$'.number_format($row['hudpay'],2).'</td> <td>' . $row['datepaid'] . '</td> <td align=right class="currency">$'.number_format($row['paidsum'],2).'</td> <td>' . $row['comments'] . '</td> </tr>'; } echo ' <tr> <td colspan=2></td> <td bgcolor="cyan" align=right>' . array_sum(array_column($slice, 'amtdue')) . '</td> <td bgcolor="cyan" align=right>' . array_sum(array_column($slice, 'amtpaid')) . '</td> <td bgcolor="99FF99" align=right>' . array_sum(array_column($slice, 'prevbal')) . '</td> <td bgcolor="FF99FF" align=right>' . array_sum(array_column($slice, 'latechg')) . '</td> <td bgcolor="99FF99" align=right>' . array_sum(array_column($slice, 'secdep')) . '</td> <td bgcolor="FF99FF" align=right>' . array_sum(array_column($slice, 'damage')) . '</td> <td bgcolor="99FF99" align=right>' . array_sum(array_column($slice, 'courtcost')) . '</td> <td bgcolor="FF99FF" align=right>' . array_sum(array_column($slice, 'nsf')) . '</td> <td bgcolor="99FF99" align=right>' . array_sum(array_column($slice, 'hudpay')) . '</td> <td bgcolor="cyan" align=right>' . array_sum(array_column($slice, 'paidsum')) . '</td>' } // ************* line 100 *********************************** ?> </table class="print"> <div class="breakhere"></div> </b></center></div></body></html> PHP: result: Parse error: syntax error, unexpected '}', expecting ';' or ',' in C:\xampp\htdocs\property\paymentlist.php on line 100
Hi, as said there's an extra closing bracket "}" at line 100. what will happen if you just remove this line below? } // ************* line 100 ***********************************
It looks like you are trying to display a payment report using PHP and MySQL. The error you are seeing may be caused by an issue with your MySQL connection or with the SQL query that you are using to retrieve data from the database. To troubleshoot this error, you could try the following: Check the values that you are using to connect to the MySQL server (e.g., the hostname, username, password, and database name). Make sure that these are correct and that you have the necessary permissions to access the database. Check the SQL query that you are using to retrieve data from the database. Make sure that the table name (paytbl) and column names are spelled correctly, and that you are using the correct syntax for your query. Use the mysqli_error() function to get more information about the error. This function will return a string containing the error message, which can help you identify the problem If you are still having trouble, you might consider printing out the values of $link, $sql, and $result to see if there is any information there that could help you understand the problem. I hope this helps! Let me know if you have any other questions
Late to the party but most of your problems stems from 20+ year out of date coding practices, and at the same time brute forcing something HTML can do all on its own without most of the stuff you're wasting time on server-side. Because if you put the headers you want on every page into a THEAD, it will automatically appear at the start of each and every page! Thus you do not need to pull all the records. You do not need to batch them the way you have. Let HTML do it's job instead! The code is also gibberish because I think you confused fetch_array -- which pulls ONE row as an array -- with fetch_all which pulls all the rows as an array. But even so all that bgcolor rubbish -- an attribute that was removed from HTML 25 years ago -- and other such failings certainly isn't helping keep your logic clean. likewise using the outmoded outdated functional wrappers for mysqli is leading you into trouble, thus things like your BROKEN error detection for the connect. Though honestly I'd kick mysqli to the curb and use PDO instead.