php embedded in html "->" interpreted as tag


I want to embed this code into an html document:

<?php $sql="img_size=VERY_BIG"; $result = $conn->query($select.$sql); $result->num_rows; echo $result ?>

the problem is that i want it to be inside an option tag (of a select menu) so i typed it like this:<option value="VERY_BIG">500x500<?php $sql="img_size=VERY_BIG"; $result = $conn->query($select.$sql); $result->num_rows; echo $result ?></option>

PROBLEM: the -> is being interpreted as the end of the tag... I have no idea what im doing wrong





You cannot just embed PHP in a HTML document.

If you want it to be parsed as PHP, you need to rename it to have .php extension.

There are actually alternative solutions for "parsing" html, but they are not recommended, since from there on, every HTML document has to 'go' through the interpreter, which can be a huge overhead.




You don't want to have a connection to the database as an inline tag.

If you still want the php to be inline, make sure you have the correct file extension ( *.php instead of *.html ). For this you will need an Apache server installed in your computer (if you want to use a localhost).

People are also looking for solutions to the problem: java - failed to insert data from android to mysql using php


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.