Immortal55 Posted March 22, 2006 Share Posted March 22, 2006 When A user clicks on an edit link for a certain story in profile.php, it takes them to writingforms.php. When writing forms is loaded I want it to load in the info from the DB into the text fields and you can edit it that way. The fields are not loading the info into them how come?profile.php code snippet:[code]<? //journal call $db = mysql_select_db('studiocommunity', $conn) or die("Unable to access user information in database, try again later."); $sql = mysql_query('select * from user_writings where user = "' . $_REQUEST['user'] . '"order by id desc') or die(mysql_error()); while($row = mysql_fetch_assoc($sql)) { stripslashes(extract($row)); echo "<a href='writings.php?id=$id'>" . $title . " - " . date("F d, Y", $date) . "</a> "; if($HTTP_SESSION_VARS['valid_user'] == $_REQUEST['user']) { echo " - [<a href='writingforms.php'>edit</a>] [delete]<br>"; } }?> [/code]and writingforms.php[code]<? session_start(); include ('dbconnect.php'); function get_writing_record($id){ $conn = db_connect(); $db = mysql_select_db('studiocommunity', $conn) or die("Unable to access user information in database, try again later."); $sql = "select * from user_writings where id = '" . $_REQUEST['id'] . "'"; $result = mysql_query($sql, $conn); return(mysql_fetch_array($result));} if (isset($HTTP_GET_VARS['id'])) $w = get_writing_record($HTTP_GET_VARS['id']); ?> <center> <form action="writingsubmit.php" method="post"> <input type="hidden" name="writing" value="<? print $HTTP_GET_VARS['id']; ?>"> <table> <tr><td align="center">Title</td></tr> <tr><td><input size="40" name="title" value="<? print $w['title']; ?>"></td></tr> <tr><td align="center">Writing Text - Can contain HTML text</td></tr> <tr><td><textarea cols="40" rows="7" name="writing_text" wrap="virtual"> <? print $w['writing']; ?> </textarea></td></tr> <tr><td align="center"><input type="submit" value="Submit"></td></tr> </table> </form> </center>[/code]I cannot figure out what is wrong, help please. Quote Link to comment https://forums.phpfreaks.com/topic/5471-more-form-problemshelp/ Share on other sites More sharing options...
phporcaffeine Posted March 22, 2006 Share Posted March 22, 2006 1.) After you do your initial SQL query and INSIDE the While loop do: var_dump($row); This will show you everything (if anything at all) that is being returned from your query. If you get nothing or NULL then your query is bombing or trying to SELECT rows that aren't there - in otherwords comb through your query syntax and make sure it is right. I noticed your WHERE filter is comming from $_REQUEST. Make sure that $_REQUEST is being populated like you think it is.2.) Once you have established that your query is returning proper and/or expected results - then it's simply a matter of setting your <INPUT>'s value to the appropriate element in the $row array.EX: echo "<input type=\"text\" name=\"my field\" id=\"my field\" value=\"$_row[my_element]\">";Also, mind your quote delimination if your echo'ing HTML via PHPI noticed that your populating the HTML value's with a $w array. According to your code/forum post, if I were trying to populate the HTML value's with the database results, I would use the $row array. Quote Link to comment https://forums.phpfreaks.com/topic/5471-more-form-problemshelp/#findComment-19556 Share on other sites More sharing options...
Immortal55 Posted March 23, 2006 Author Share Posted March 23, 2006 I realized that I was not populating my $_REQUEST like I thought I was. The link to the edit was just writingforms.php, not writingforms.php?id=. I think that was my problem, although I cannot try it right now. Would you reccoment I get rid of the $w array and just use the $row function? Quote Link to comment https://forums.phpfreaks.com/topic/5471-more-form-problemshelp/#findComment-19801 Share on other sites More sharing options...
Immortal55 Posted March 23, 2006 Author Share Posted March 23, 2006 Hmmm, alright, Yeah my idea did not work....Can anyone look over my scripts again and see if they cant find out what is wrong? Quote Link to comment https://forums.phpfreaks.com/topic/5471-more-form-problemshelp/#findComment-19967 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.