I have tried loading my php files to my web hosting server but the files have an error I cannot figure out . My files begin with <?php and end in ?> and then I changed to <? and ended with ?> but the server says there is a problem with that beginning! I don't know how to fix it. The server uses php extension mysqli version 7.4.30

It is correct for your PHP code to begin with <?php and to end with ?>. However, if you have regular HTML mixed into the same file, you want to make sure that your opening and closing PHP blocks don't encapsulate your regular HTML code as well.

If you could post the full .php page here, that would be very helpful to be able to diagnose what might be going wrong.

I was just thinking ...

Something else you can do is just create a new PHP file that only contains the following:

<?php echo 'Hello World'; ?>

And then run it and see if it prints out 'Hello World'. If it does, you know PHP is working correctly, and you have a bug in your PHP script.

<?php
echo 'Hello World'; ?>
I did run the above script on an online php editor and it outputted 'Hello World'!
However, with my server database php administrator, it brought 5 errors and referenced line numbers that do not even exist in the page! 11 of them when the page has only two lines of script! I think my online server database php administrator has issues!

What are you calling a "server database php administrator" is actually phpMyAdmin, a php-based web script used to provide a user interface for MySQL databases.

The reason that it isn't working is because you are entering PHP code in a text area designed for SQL database queries. It is not able to interpret PHP code.

... Oh, but the good news is that phpMyAdmin was written in PHP, and since it's executing on your server, that means your server is correctly configured to execute php files.

You need to upload your PHP file(s) to your web server and then execute them directly from a web browser.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.