Jump to content

Problem with my edit page


aquatsr

Recommended Posts

OK. I've been writing and rewriting this code over and over, but it just won't do what I want it to. Basically I have one page which works fine (1st block of code) which queries the database for all entries and has you choose one.

<?php//Login stuff cut out, all works perfect to fetch resultswhile ($row = mysql_fetch_array($result)) {$id = $row['song_id'];$title = $row['title'];$artist = $row['artist'];$option_block .= "<option value =\"$id\">$title by $artist</option>";}$display_block = "<form method=\"POST\" action=\"modify_test.php\"><p><strong>Lyrics of </strong><select name=\"id\">$option_block</select> <input type=\"submit\" name=\"submit\" value=\"Select this Entry\"></p></form>";}?><p><center>Select a lyrics entry from the list below</center></p><?php echo "<center>$display_block</center><br />"; ?>

However, once I get to the page, modify_test.php, none of the results display given this second block of code:

<?php//Again login and connection info... is all correct.//I'm assuming my problem begins here.$sql = "SELECT title, artist, album, release_year, genre, language, date_added, added_by, english_lyrics, translation FROM songs WHERE song_id = \"$id\"";echo $id; /* No result from this test */$result = mysql_query($sql);if (!$result){die ("<center>Could not query the database: <br />". mysql_error()."</center>");}else {while ($row = mysql_fetch_array($result)) {$title = $row['title'];$artist = $row['artist'];$album = $row['album'];$year = $row['release_year'];$genre = $row['genre'];$language = $row['language'];$date = $row['date_added'];$user = $row['added_by'];$lyrics = $row['english_lyrics'];$translation = $row['translation'];}}}?><div id="content"><center>This record was originally added by <?php echo "$user";/* echo date("m/d/y/ G.i:s", $date);*/ ?>.<form action="update.php" method="POST">Song<br /><input type="text" name="title" size="50" value="<?php echo htmlspecialchars(stripslashes($title)); ?>" /><br /><br />Artist<br /><input type="text" name="artist" size="50" value="<?php echo htmlspecialchars(stripslashes($artist)); ?>" /><br /><br />Album Name<br /><input type="text" name="album" size="50" value="<?php echo htmlspecialchars(stripslashes($album)); ?>" /><br /><br />Release Year<br /><input type="text" name="releaseyear" size="50" value="<?php echo htmlspecialchars(stripslashes($year)); ?>" /><br /><br />Genre<br /><input type="text" name="genre" size="50" value="<?php echo htmlspecialchars(stripslashes($genre)); ?>" /><br /><br />Lyric Language<br /><input type="text" name="language" size="50" value="<?php echo htmlspecialchars(stripslashes($language)); ?>" /><br /><br />English Lyrics<br /><textarea name="englyrics" rows="6" cols="50" value="<?php echo htmlspecialchars(stripslashes($lyrics)); ?>"</textarea><br /><br /><?php if ($translation != "") {echo ("Translation<br /><textarea name=\"translation\" rows=\"6\" cols=\"50\" value=\"<?php echo htmlspecialchars(stripslashes($translation)); ?>\"</textarea><br /><br />"); } ?><input type="submit" name="submit" value="Modify Entry" /><br /></form></center></div><div id = "bottombar"><center><font color="red">Warning, warning! This page is not yet active!!</font></center></div>

Can anyone tell me why almost all the POSTDATA isn't showing up? The only thing that shows up are a lot of empty fields (except for the language field, which reads "english"). I'd greatly appreciate a solution to this problem.

Link to comment
Share on other sites

There should be only one POSTDATA, the 'id', from what I understand.Is there any $id = $_POST['id] at the top? If there isn't, the script will work only with 'register globals' on.Also, because it is user input, you should use:$sql = "SELECT title, artist, album, release_year, genre, language, date_added, added_by, english_lyrics, translation FROM songs WHERE song_id = '".mysql_real_escape_string($_POST['id'])."'";

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...