Jump to content

[SOLVED] putting mysql resluts in text box's


kev wood

Recommended Posts

i am trying to get the results from my mysql query and put them into text box'x so i can edit them.  i keep getting errors with the code though.

 

here is my code

 

$sql = ("SELECT * FROM $table WHERE id = $id");
$result = mysql_query($sql);

$row = mysql_fetch_array($result) or die(mysql_error());
echo '<form action="insert.php" method="post">'
echo 'Date: <input type="text" name="date" value="<?=$row['date'];?>" /><br /><br>'
echo 'Title:  <input type="text" name="title" value="<?=$row['title'];?>" /><br /><br />'
echo 'Article:<br /><textarea cols="50" rows="10" name="article" value="<?=$row['article'];?>" onkeyup="textLimit(this, 500);"></textarea><br />'
echo '<input type="submit" />'
echo '</form>'

 

the error i am getting is

 

Parse error: parse error, unexpected T_ECHO, expecting ',' or ';'

 

it says the error is on the line underneath the beginning of the form.  do i need to keep echoiing each line out?

 

any help with this would be great

i have now put that section of code like this

 

value="<?=$row[\'date\'];?>"

 

but when the page is run the form is displaying but instead of putting the information into the box's i am getting

<?=$row[\'date\'];?>

inside of them instead of the text.

try:

 


$sql = ("SELECT * FROM $table WHERE id = $id");
$result = mysql_query($sql);

$row = mysql_fetch_array($result) or die(mysql_error());
echo "<form action=\"insert.php\" method=\"post\">";
echo "Date: <input type=\"text\" name=\"date\" value=\"{$row['date']}\" /><br /><br>";
echo "Title:  <input type=\"text\" name=\"title\" value=\"{$row['title']}\" /><br /><br />";
echo "Article:<br /><textarea cols=\"50\" rows=\"10\" name=\"article\" value=\"{$row['article']}\" onkeyup=\"textLimit(this, 500)\"</textarea><br />";
echo "<input type=\"submit\" />";
echo "</form>";

echo "Date: <input type='text' name='date' value=\"$row['date']\" /><br /><br />";

 

this is the one that will work, and just in case it doesnt, make it:

echo "Date: <input type='text' name='date' value=\"$row[date]\" /><br /><br />";

without the 's around date.

sorted this line is wrong

 

echo "Article:<br /><textarea cols=\"50\" rows=\"10\" name=\"article\" value=\"{$row['article']}\" onkeyup=\"textLimit(this, 500)\"</textarea><br />";

 

it should be

 

echo "Article:<br /><textarea cols=\"50\" rows=\"10\" name=\"article\" onkeyup=\"textLimit(this, 500)\">{$row['article']}</textarea><br />";

It was probably something else causing the error.

 

 

 

Burn's should also work just fine.

 

And using ' is fine.

ive gotten errors from it before and it just didnt work sometimes so i didnt know. just trying to help.

sorted this line is wrong

 

echo "Article:<br /><textarea cols=\"50\" rows=\"10\" name=\"article\" value=\"{$row['article']}\" onkeyup=\"textLimit(this, 500)\"</textarea><br />";

 

it should be

 

echo "Article:<br /><textarea cols=\"50\" rows=\"10\" name=\"article\" onkeyup=\"textLimit(this, 500)\">{$row['article']}</textarea><br />";

 

so it is :P

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.