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

$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;

$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

Edited by CanadianGSX: n/a

7 Years
Discussion Span
Last Post by CanadianGSX

OOPS...the line

<td width='200'><input type='text' name='fname' id='fname' value="<?php echo $row['$fname']; ?>"></td>

should have been

<td width='200'><input type='text' name='fname' id='fname' value="<?php echo $row['fname']; ?>"></td>

Are you serving the page as php? For example, does it have the php extension.

Votes + Comments
You are too clever by far KK

(insert choice words here)

In my grandeur I figured for testing purposes I'd just embed it in my html file not thinking it wasn't being served as php...

Thanks, my brain thanks you too :)

Amazing how it works the way it should when used the way it was meant to be :P

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.