Tom Granot
Tom Granot

Reputation: 1850

Hidden Form Field Not Storing Variable

I have the following form:

form

<?php
echo '<td><form action="episodesdelete.php" method="POST">';
echo '<input type="hidden" name="epid" value="'.$row['epid'].'">';
echo '<input type="submit" value="Delete"></form></td>';
?>

Which is part of a function to display MySQL data in an HTML table.

For some reason, when i look at the hidden field with FireBug, it is empty. Could you please advise due to what that can be?

Upvotes: 0

Views: 322

Answers (1)

TehShrike
TehShrike

Reputation: 10084

Where is $row assigned its value?

A very common mistake is to not check for failed queries. Make sure to check every query execution for errors, like so:

$result = mysql_query($query_text) or die("Error running query " . mysql_error());

If that line gets passed (the query succeeds), make sure that $row is getting assigned a valid value (by a function like mysql_fetch_array perhaps?).

And, if that checks out, run the query yourself from the command line to verify that the results are what you expect (and that the query is not actually returning an empty string).

Upvotes: 1

Related Questions