Filip Ionita
Filip Ionita

Reputation: 67

Identifying MySQL ID in a form

Using the following code:

<?php
print"<form name='delete' action="" method='POST'>
<input type='text' name='ID' value=".$info['ID'].">
<input type='submit' value='Delete Car' onclick='deleteRecord(); return false;'>
</form>";
?>

Is giving me the following error message, which in turn won't let me load the page:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in (etc)...

It is meant to get the ID of an MySQL record from user input.

What is wrong with that? I have another file where it works without any problems.

Upvotes: 1

Views: 96

Answers (3)

Axel A. Garc&#237;a
Axel A. Garc&#237;a

Reputation: 683

Use this code:

<form name="delete" action="" method="POST">
    <!-- Use php echo instead of print -->
    <input type="text" name="id" value="<?php echo $info['ID'] ?>">
    <!-- Try not to use inline javascript -->
    <button type="submit" onClick="deleteRecord(); return false"></button>
</form>

In action="" the quotes where messing with your php, so I recommend not to print html tags with php. Hope it helps

Upvotes: 1

Simon Carlson
Simon Carlson

Reputation: 1989

Look at <form name='delete' action="". I think the problem is the double quotes. Change it to <form name='delete' action='' and see what happens.

Upvotes: 2

pilsetnieks
pilsetnieks

Reputation: 10420

Perhaps a missing PHP closing tag somewhere nearby? As in ?>

Or just a syntax error somewhere in the file.

Upvotes: 0

Related Questions