Good morning, I'll keep this simple, I have a form that I need to populate with the contects of a MySQL database. I've tested that the 'gathering information' script works properly via a SELECT command. However, when I try to set the value of a text form field using the results, I keep getting this instead of the value itself...
<?php echo $row; ?>
here is the assosciated code. It is contained within an HTML file after the body tag
<?php
$DBhost = "localhost";
$DBuser = "xxxx";
$DBpass = "xxxx";
$DBName = "xxxx";
$table = "xxxx";
# Defining variables with form POST data
$selectPart = htmlspecialchars($_POST['selectPart']);
mysql_connect("$DBhost","$DBuser","$DBpass") or die(mysql_error());
mysql_select_db("$DBName") or die(mysql_error());
$query = "SELECT * FROM xxxx WHERE partID=$selectPart";
$result = mysql_query($query);
if (!$result) {
$message = 'invalid Query: ' . mysqyl_error() . "\n";
$message .= 'Whole Query: ' . $query;
die($message);
}
$row = mysql_fetch_assoc($result);
?>
This part works as I've tested it with an echo $row; and so on for the other fields in the array.
When I try to populate the form fields however,
<td width='200'><input type='text' name='fname' id='fname' value="<?php echo $row['$fname']; ?>"></td>
I get the line I mentioned above (<?php echo $row; ?>)in the field instead of the value.
Any help is appreciated!
- Lou