Unexpected "<" error in php

Closed
kashish123 Posts 1 Registration date Friday December 23, 2016 Status Member Last seen December 23, 2016 - Dec 23, 2016 at 03:37 AM
chandrashekhargoka Posts 1 Registration date Tuesday April 4, 2017 Status Member Last seen April 4, 2017 - Apr 4, 2017 at 10:18 AM
Hello,

I just started learning php and I was doing form handling. I got this this error on xampp server when I tried to run my code.
The error was :

Parse error: syntax error, unexpected '<', expecting end of file in C:\xampp\htdocs\catalog.php on line 2

Here is my code :

<?php
<input type="text" name="product_id">
<select name="category">
<option value="ovenmitt">Pot Holder</option>
<option value="fryingpan">Frying Pan</option>
<option value="torch">Kitchen Torch</option>
</select>
<input type="submit" name="submit">
</form>Here are the submitted valuesproduct_id: <?php print $_POST['product_id'] ?? ''?>
<br/>
category: <?php print $_POST['category'] ?? ''?>

?>
Can anyone please help how could this error be handled. Thanks in advance :)

2 responses

yg_be Posts 22711 Registration date Sunday June 8, 2008 Status Contributor Last seen April 21, 2024 5
Dec 23, 2016 at 01:42 PM
hi, I suggest removing the first line and the last line.
0
chandrashekhargoka Posts 1 Registration date Tuesday April 4, 2017 Status Member Last seen April 4, 2017
Updated on Apr 4, 2017 at 10:30 AM
Seems you didn't close your tags properly. Can you once remove these tags and try again.
<?php print $_POST['product_id'] ?? ''?>
<br/>
category: <?php print $_POST['category'] ?? ''?>

You can see here for basic php syntax :https://www.onlinetutorialspoint.com/php/php-syntax-example-tutorials.html
0