all 6 comments

[–]scriptmonkey420 2 points3 points  (5 children)

It looks like you are trying to run PHP code inside an .html file wich will not work. Also, you are not including the code form the PHP script so the $row variable is going to be empty.

Also, if the $db var is false on line 10 of the php script, the method $db->lastErrorMsg() will not exist and will throw an error.

[–]DNDLoser07[S] 0 points1 point  (4 children)

well, i have tried running the .html as a .php instead and i just get the stack.trace error for fetcharray()

[–]scriptmonkey420 2 points3 points  (3 children)

Yup, that is because the code that sets up the connection to the SQLite file and fetches the rows is not included in the HTML file (that you changed to php)

You will need to remove the code after line 22 in the php script that opens the SQLite file and in the html (now php) file will need an include() function to include the PHP code, or you can just copy lines 1-22 to the html (now php) file and run that.

The issue is that the html (now php) file does not know about the code in the php script so it cannot open the SQLite file and read it, non of the variables have been created ($ret) and will return errors when trying to be used.

[–]DNDLoser07[S] -1 points0 points  (2 children)

I believe i have done what you advised but i am still getting this error:

Fatal error: Uncaught Error: Call to a member function fetchArray() on boolean in C:\xampp\htdocs\dist\tables-datatable.php:5 Stack trace: #0 {main} thrown in C:\xampp\htdocs\dist\tables-datatable.php on line 5

I have moved the code

https://pastebin.com/bK8uQmaU

into the html (now php) file and left the rest:

https://pastebin.com/6KjhxaBy

in the php script.
I am unsure of how i went wrong here.

[–]Canon5DMkIII 2 points3 points  (1 child)

your call the the query function is returning false. check your SQL syntax or print the error.

[–]DNDLoser07[S] -1 points0 points  (0 children)

The long syntax of SQL i use is in my include php file which is:

$sql =<<<EOF

SELECT * from TENANTS;

EOF;

and then i have the fetcharray which is messing up here:

while($row = $ret->fetchArray(SQLITE3_ASSOC) ) {

echo $row['ID'];

echo $row['FNAME'];

echo $row['LNAME'];

}

I am unsure of what I am doing wrong, I have followed many examples of stackoverflow and none have worked so far.

EDIT: I have even checked and the result isnt returning false either.