-1

I'm brand new to amp, trying to build a new amp page, and wanted to include php to access a mysql database. However, I'm getting this error:

The tag '?php' is disallowed.

Seems I must be missing something obvious, but I find zero reference to PHP in the documentation nor here in stackOverflow. Is php completely disallowed in amp? If so, what are the database alternatives?

Thank you!

6
  • Something else is going on. Your Server Executes PHP before any Client code is read. You do have a Server?
    – StackSlave
    Feb 27, 2018 at 0:25
  • Are you actually using PHP?
    – Dai
    Feb 27, 2018 at 0:25
  • 1
    your php cant be running if you see this.
    – user8011997
    Feb 27, 2018 at 0:54
  • 1
    Right-click, view source, if you see your PHP code, you're not running the code through PHP. Feb 27, 2018 at 1:01
  • @geekomancer ?php should be <?php Feb 27, 2018 at 4:49

3 Answers 3

0

It sounds like you you're trying to use PHP on a regular HTML page. Change your AMP page's extension to .php so that PHP will run it before it gets served.

If you're already using .php file and its hosted on a server that can handle PHP, then most likely you have some malformed php code in your page.

0

I think you are getting the message "The tag '?php' is disallowed." because you are attempting to validate a php file by pasting the file into the AMP validator. The validator is not a server and does not run the php parser prior to validating code.

The proper way to validate an AMP php file is make it a web page and have the validator pull the file from the server. This way, the server will parses the php file and create the intended code prior to the validator assessing it.

0

Duh. I was running it on a different type of local server, not the usual Apache. I feel dumb. :/

Also, I thought I answered this already, but my answer seems to have not posted. Thanks for your help, everybody. Sorry for the dumb question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.