Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.