kev wood Posted October 22, 2008 Share Posted October 22, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/ Share on other sites More sharing options...
peranha Posted October 22, 2008 Share Posted October 22, 2008 After all your echo statements you need a ; echo '<form action="insert.php" method="post">' echo '<form action="insert.php" method="post">'; Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671707 Share on other sites More sharing options...
beansandsausages Posted October 22, 2008 Share Posted October 22, 2008 how can you use this <?=$row['date'];?> in a php tag that is open ??? wouldnt you have to close the open tag first? Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671710 Share on other sites More sharing options...
kev wood Posted October 22, 2008 Author Share Posted October 22, 2008 that was my next question. i have a column named date but when i use this in the code it is highlighted, how can i just get it to display the info held in the date column. Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671723 Share on other sites More sharing options...
revraz Posted October 22, 2008 Share Posted October 22, 2008 <? is short for opening PHP tags. If you are in a PHP block, remove the <? Use echo instead of = Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671726 Share on other sites More sharing options...
kev wood Posted October 22, 2008 Author Share Posted October 22, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671728 Share on other sites More sharing options...
kev wood Posted October 22, 2008 Author Share Posted October 22, 2008 i will try that now. if you read this before the edit forgot i had changed Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671729 Share on other sites More sharing options...
beansandsausages Posted October 22, 2008 Share Posted October 22, 2008 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671731 Share on other sites More sharing options...
revraz Posted October 22, 2008 Share Posted October 22, 2008 echo "Date: <input type='text' name='date' value=\"$row['date']\" /><br /><br />"; Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671732 Share on other sites More sharing options...
R4nk3d Posted October 22, 2008 Share Posted October 22, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671734 Share on other sites More sharing options...
kev wood Posted October 22, 2008 Author Share Posted October 22, 2008 no i am getting this error now Parse error: parse error, unexpected T_STRING, expecting ',' or ';' on the article line Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671737 Share on other sites More sharing options...
revraz Posted October 22, 2008 Share Posted October 22, 2008 Burn's should also work just fine. And using ' is fine. Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671739 Share on other sites More sharing options...
revraz Posted October 22, 2008 Share Posted October 22, 2008 You probably forgot a ending ; on the line before. Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671740 Share on other sites More sharing options...
kev wood Posted October 22, 2008 Author Share Posted October 22, 2008 burns is working now. why i got errors from it before i dont. i copied and pasted it in and got errors just done it again and there are no errors now. just not putting the text into the text box Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671745 Share on other sites More sharing options...
R4nk3d Posted October 22, 2008 Share Posted October 22, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671750 Share on other sites More sharing options...
kev wood Posted October 22, 2008 Author Share Posted October 22, 2008 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 />"; Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671752 Share on other sites More sharing options...
revraz Posted October 22, 2008 Share Posted October 22, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671757 Share on other sites More sharing options...
beansandsausages Posted October 22, 2008 Share Posted October 22, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671761 Share on other sites More sharing options...
R4nk3d Posted October 22, 2008 Share Posted October 22, 2008 dont forget to use the topic solved button Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671768 Share on other sites More sharing options...
kev wood Posted October 22, 2008 Author Share Posted October 22, 2008 i will now thanks for all your help on this. Quote Link to comment https://forums.phpfreaks.com/topic/129570-solved-putting-mysql-resluts-in-text-boxs/#findComment-671772 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.