Version 2 (modified by 12 months ago) ( diff ) | ,
---|
PHP
The 825gen2 includes PHP which combined with the Apache Web Server allows for powerful web features.
root@imx8mq-var-dart:~# php -v PHP 8.1.10 (cli) (built: Aug 30 2022 16:09:36) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.10, Copyright (c) Zend Technologies
Accessing MySQL database from php:
Make sure MySQL is configured first. Refer to MySQL page MySQL (MariaDB)
Create a simple test php file to read from the database
cd /usr/share/apache2/default-site/htdocs nano readmysql.php
<!DOCTYPE html> <html lang="en"> <head> <title>825 MySQL Test</title> </head> <body> <?php $conn = mysqli_connect('127.0.0.1', 'dbuser', '81440', 'test'); if(!$conn) { echo 'Connection error: ' . mysqli_connect_error(); } else { $sql = 'select * from test_tbl;'; $result = $conn->query($sql); if($result->num_rows > 0) { echo '<table><tr><th>Title</th><th>Description</th></tr>'; while($row = $result->fetch_assoc()) { $title = $row['title']; $description = $row['description']; echo '<tr><td>' . $title . '</td><td>' . $description . '</td></tr>'; } echo '</table>'; } } ?> </body> </html>
Test with PC on same network as 825.
Attachments (4)
- 825webpagephp.png (9.5 KB ) - added by 12 months ago.
- 825webdevtools.png (18.8 KB ) - added by 12 months ago.
- 825webphpsqlite.png (10.7 KB ) - added by 12 months ago.
- 825webpage_ids_captured_images.png (167.7 KB ) - added by 9 months ago.
Download all attachments as: .zip
Note:
See TracWiki
for help on using the wiki.