This question already has an answer here:
I am trying to add products
to my database. I am creating a PHP page to allow me to select the artist by name or enter a new one, upload an image, and enter the details of the product.
When I run my code, I am not getting no where forward.
I get an error on this line of my code:
<p>
<b>Print Name: </b>
<input type="text" name="print_name" size="30" maxlength="60"
value="<?php if (isset($_POST['print_name']))
echo htmlspecialchars($_POST['print_name']);?>" />
</p>
The error is:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING
</div>
Your code should be like below :
<p>
<b>Print Name: </b>
<input type="text" name="print_name" size="30" maxlength="60" value="<?php echo (isset($_POST['print_name'])) ? htmlspecialchars($_POST['print_name']) : '' ;?>"
/>
</p>
You are using Unary operator in wrong way :
The structure of unary is :
<?php echo (condition) ? true : false ; ?>
You can try this you have to start and over curly brackets
<input type="text" name="print_name" size="30" maxlength="60" value="<?php if (isset($_POST['print_name'])){
echo htmlspecialchars($_POST['print_name']);}?>">