Zeradin Posted August 20, 2008 Share Posted August 20, 2008 I get the form populated and everything, but when I hit submit when it is at upalbum.php?action=edit&id=71 I get the "you edited!" line but the file it says i edited is null like "reviews/xml/.xml" Thanks in advance // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $mquery = 'SELECT * FROM users'; // execute query $mresult = mysql_query($mquery) or die ("Error in query: $mquery. ".mysql_error()); // close connection mysql_close($connection); $eid = $_GET['id']; $action = $_GET['action']; //if it is an upload not an edit if ($eid == NULL && $action != "edit" && $_POST['albumedit'] == NULL) { if(!isset($_POST['albumsubmit'])) { ?> <!-- Upload Form --> <span class="newstitle"><u>Album Upload</u></class><br /><br /> <form method="POST" action="<?php $_SERVER['PHP_SELF']?>"> <strong>Poster</strong><br /> <select size="1" name="poster"> <?php while(list($id, $username) = mysql_fetch_row($mresult)) { echo '<option value="'.$id.'">'.$username.'</option>'; } ?> </select><br /><br /> <strong>Title</strong><br /> <input type="text" name="title" size="20"><br /> <strong>Subtitle</strong><br /> <input type="text" name="subtitle" size="20"><br /> <br /> <strong>Image Location</strong><br /> <input type="text" name="image" size="20"><br /> <strong>Release Date</strong><br /> <input type="text" name="rdate" size="20"><br /> <br /> <strong>Record Label</strong><br /> <input type="text" name="rcomp" size="20"><br /> <br /> <strong>Link1 address</strong><br /> <input type="text" name="add1" size="20"><br /> <strong>Link1 text</strong><br /> <input type="text" name="text1" size="20"><br /> <br /><br /> <strong>Review</strong><br /> <textarea rows="20" name="review" cols="80"></textarea> <br /> <br /> <input type="submit" value="Submit" name="albumsubmit" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'"/> </form><br /> <!-- End Upload Form --> <?php } if(isset($_POST['albumsubmit']) && $action != "edit") { $title = $_POST['title']; $stitle = $_POST['subtitle']; $rdate = $_POST['rdate']; $rcomp = $_POST['rcomp']; $image = $_POST['image']; $add1 = $_POST['add1']; $text1 = $_POST['text1']; $info = $_POST['review']; $poster = $_POST['poster']; //get poster names and ids // set database server access variables: $host = "localhost"; $user = "hypboard_hyp"; $pass = "d31373"; $db = "hypboard_hypnet"; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $mquery = 'SELECT * FROM users WHERE id = "'.$poster.'"'; // execute query $mresult = mysql_query($mquery) or die ("Error in query: $mquery. ".mysql_error()); $row = mysql_fetch_assoc($mresult); $postername= $row['username']; // create query $query = "INSERT INTO reviews (title, reviewer, type) VALUES ('$title', '$postername', 'album')"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $file = "../reviews/xml/".mysql_insert_id().".xml"; // open file $fh = fopen($file, 'w') or die('Could not open file!'); $output = '<?xml version="1.0"?>'; $output.= "<album>\n"; $output.= "<title>".$title."</title>\n"; $output.= "<subtitle>".$stitle."</subtitle>\n"; $output.= "<image>".$image."</image>\n"; $output.= "<rdate>".$rdate."</rdate>\n"; $output.= "<rcomp>".$rcomp."</rcomp>\n"; $output.= "<links>\n"; $output.= "<add1>".$add1."</add1>\n"; $output.= "<text1>".$text1."</text1>\n"; $output.= "</links>\n"; $output.= "<info>".$info."</info>\n"; $output.="</album>\n"; fwrite($fh, $output); // close file fclose($fh); echo "you uploaded an album!! (id=".$file." now what? I haven't really added anything else to this yet"; // close connection mysql_close($connection); } } //------------------------------------------------------------------------------------EDIT------------------------------------------------------------------------------------// //edit mode! else { if(!isset($_POST['albumedit'])) { $file = "../reviews/xml/".$eid.".xml"; $xml = simplexml_load_file($file) or die ("Unable to load XML file!"); //<!-- Upload Form --> echo '<span class="newstitle"><u>Game Review Upload</u></class><br /><br /> <form method="POST" action="'.$_SERVER['PHP_SELF'].'"> <strong>Title</strong><br /> <input type="text" name="title" size="20" value="'.$xml->title.'"><br /> <strong>Subtitle</strong><br /> <input type="text" name="subtitle" size="20" value="'.$xml->subtitle.'"><br /> <br /> <strong>Image Location</strong><br /> <input type="text" name="image" size="20" value="'.$xml->image.'"><br /> <strong>Release Date</strong><br /> <input type="text" name="rdate" size="20" value="'.$xml->rdate.'"><br /> <br /> <strong>Record Company</strong><br /> <input type="text" name="rdate" size="20" value="'.$xml->rcomp.'"><br /> <br /> <strong>Link1 address</strong><br /> <input type="text" name="add1" size="20" value="'.$xml->links->add1.'"><br /> <strong>Link1 text</strong><br /> <input type="text" name="text1" size="20" value="'.$xml->links->text1.'"><br /> <br /><br /> <strong>Review</strong><br /> <textarea rows="30" name="info" cols="100">'; echo $xml->info; echo '</textarea> <br /> <br /> <input type="submit" value="Submit" name="albumedit" class="btn" onmouseover="this.className=\'btn btnhov\'" onmouseout="this.className=\'btn\'"/> </form><br />'; // <!-- End Upload Form --> } else { $title = $_POST['title']; $stitle = $_POST['subtitle']; $image = $_POST['image']; $rdate = $_POST['rdate']; $rcomp = $_POST['rcomp']; $add1 = $_POST['add1']; $text1 = $_POST['text1']; $info = $_POST['info']; $poster = $_POST['poster']; $file2 = "../reviews/xml/".$eid.".xml"; echo $eid; echo $file2; // open file $fh2 = fopen($file2, "w+") or die('Could not open file!'); $output = '<?xml version="1.0"?>'; $output.= "<album>\n"; $output.= "<title>".$title."</title>\n"; $output.= "<subtitle>".$stitle."</subtitle>\n"; $output.= "<image>".$image."</image>\n"; $output.= "<rdate>".$rdate."</rdate>\n"; $output.= "<rcomp>".$rcomp."</rcomp>\n"; $output.= "<links>\n"; $output.= "<add1>".$add1."</add1>\n"; $output.= "<text1>".$text1."</text1>\n"; $output.= "</links>\n"; $output.= "<info>".$info."</info>\n"; $output.="</album>\n"; fwrite($fh2, $output2); // close file fclose($fh2); echo $eid; echo "you edited an album review!! (id=".$file2." now what? I haven't really added anything else to this yet"; } } ?> Link to comment https://forums.phpfreaks.com/topic/120532-xml-edit-not-editing-xml/ Share on other sites More sharing options...
Zeradin Posted August 20, 2008 Author Share Posted August 20, 2008 ok i decided to not edit the xml file, let it create the new one, and just delete out the SQL entry for it. but... it's not deleting the old entry and it's not grabbing the username from the old entry. So I've determined that it doesn't get the $eid, but it should? what the hell <?php // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $mquery = 'SELECT * FROM users'; // execute query $mresult = mysql_query($mquery) or die ("Error in query: $mquery. ".mysql_error()); // close connection mysql_close($connection); $eid = $_GET['id']; $action = $_GET['action']; //if it is an upload not an edit if ($eid == NULL && $action != "edit" && !isset($_POST['albumedit'])) { if(!isset($_POST['albumsubmit'])) { ?> <!-- Upload Form --> <span class="newstitle"><u>Album Upload</u></class><br /><br /> <form method="POST" action="<?php $_SERVER['PHP_SELF']?>"> <strong>Poster</strong><br /> <select size="1" name="poster"> <?php while(list($id, $username) = mysql_fetch_row($mresult)) { echo '<option value="'.$id.'">'.$username.'</option>'; } ?> </select><br /><br /> <strong>Title</strong><br /> <input type="text" name="title" size="20"><br /> <strong>Subtitle</strong><br /> <input type="text" name="subtitle" size="20"><br /> <br /> <strong>Image Location</strong><br /> <input type="text" name="image" size="20"><br /> <strong>Release Date</strong><br /> <input type="text" name="rdate" size="20"><br /> <br /> <strong>Record Label</strong><br /> <input type="text" name="rcomp" size="20"><br /> <br /> <strong>Link1 address</strong><br /> <input type="text" name="add1" size="20"><br /> <strong>Link1 text</strong><br /> <input type="text" name="text1" size="20"><br /> <br /><br /> <strong>Review</strong><br /> <textarea rows="20" name="review" cols="80"></textarea> <br /> <br /> <input type="submit" value="Submit" name="albumsubmit" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'"/> </form><br /> <!-- End Upload Form --> <?php } if(isset($_POST['albumsubmit'])) { $title = $_POST['title']; $stitle = $_POST['subtitle']; $rdate = $_POST['rdate']; $rcomp = $_POST['rcomp']; $image = $_POST['image']; $add1 = $_POST['add1']; $text1 = $_POST['text1']; $info = $_POST['review']; $poster = $_POST['poster']; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $mquery = 'SELECT * FROM users WHERE id = "'.$poster.'"'; // execute query $mresult = mysql_query($mquery) or die ("Error in query: $mquery. ".mysql_error()); $row = mysql_fetch_assoc($mresult); $postername= $row['username']; // create query $query = "INSERT INTO reviews (title, reviewer, type) VALUES ('$title', '$postername', 'album')"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $file = "../reviews/xml/".mysql_insert_id().".xml"; // open file $fh = fopen($file, 'w') or die('Could not open file!'); $output = '<?xml version="1.0"?>'; $output.= "<album>\n"; $output.= "<title>".$title."</title>\n"; $output.= "<subtitle>".$stitle."</subtitle>\n"; $output.= "<image>".$image."</image>\n"; $output.= "<rdate>".$rdate."</rdate>\n"; $output.= "<rcomp>".$rcomp."</rcomp>\n"; $output.= "<links>\n"; $output.= "<add1>".$add1."</add1>\n"; $output.= "<text1>".$text1."</text1>\n"; $output.= "</links>\n"; $output.= "<info>".$info."</info>\n"; $output.="</album>\n"; fwrite($fh, $output); // close file fclose($fh); echo "you uploaded an album!! (id=".$file." now what? I haven't really added anything else to this yet"; // close connection mysql_close($connection); } } //------------------------------------------------------------------------------------EDIT------------------------------------------------------------------------------------// //edit mode! else { if(!isset($_POST['albumedit'])) { $file = "../reviews/xml/".$eid.".xml"; $xml = simplexml_load_file($file) or die ("Unable to load XML file!"); //<!-- Upload Form --> echo '<span class="newstitle"><u>Game Review Upload</u></class><br /><br /> <form method="POST" action="'.$_SERVER['PHP_SELF'].'"> <strong>Title</strong><br /> <input type="text" name="title" size="20" value="'.$xml->title.'"><br /> <strong>Subtitle</strong><br /> <input type="text" name="subtitle" size="20" value="'.$xml->subtitle.'"><br /> <br /> <strong>Image Location</strong><br /> <input type="text" name="image" size="20" value="'.$xml->image.'"><br /> <strong>Release Date</strong><br /> <input type="text" name="rdate" size="20" value="'.$xml->rdate.'"><br /> <br /> <strong>Record Company</strong><br /> <input type="text" name="rcomp" size="20" value="'.$xml->rcomp.'"><br /> <br /> <strong>Link1 address</strong><br /> <input type="text" name="add1" size="20" value="'.$xml->links->add1.'"><br /> <strong>Link1 text</strong><br /> <input type="text" name="text1" size="20" value="'.$xml->links->text1.'"><br /> <br /><br /> <strong>Review</strong><br /> <textarea rows="20" name="review" cols="80">'; echo $xml->info; ?></textarea><br /><br /> <input type="submit" value="Submit" name="albumedit" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'"/> </form><br /> <?php // <!-- End Upload Form --> } else { $title = $_POST['title']; $stitle = $_POST['subtitle']; $image = $_POST['image']; $rdate = $_POST['rdate']; $rcomp = $_POST['rcomp']; $add1 = $_POST['add1']; $text1 = $_POST['text1']; $info = $_POST['info']; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $uquery = 'SELECT * FROM reviews WHERE id = "'.$eid.'"'; $uresult = mysql_query($uquery) or die ("Error in query: $dquery. ".mysql_error()); $urow = mysql_fetch_assoc($uresult); $postername = $urow['reviewer']; // create delete query $dquery = 'DELETE FROM reviews WHERE id = "'.$eid.'"'; // execute delete query $dresult = mysql_query($dquery) or die ("Error in query: $dquery. ".mysql_error()); // create query $query = "INSERT INTO reviews (title, reviewer, type) VALUES ('$title', '$postername', 'album')"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $file = "../reviews/xml/".mysql_insert_id().".xml"; // open file $fh = fopen($file, "w") or die('Could not open file!'); $output = '<?xml version="1.0"?>'; $output.= "<album>\n"; $output.= "<title>".$title."</title>\n"; $output.= "<subtitle>".$stitle."</subtitle>\n"; $output.= "<image>".$image."</image>\n"; $output.= "<rdate>".$rdate."</rdate>\n"; $output.= "<rcomp>".$rcomp."</rcomp>\n"; $output.= "<links>\n"; $output.= "<add1>".$add1."</add1>\n"; $output.= "<text1>".$text1."</text1>\n"; $output.= "</links>\n"; $output.= "<info>".$info."</info>\n"; $output.="</album>\n"; fwrite($fh, $output); // close file fclose($fh); echo $eid; echo "you edited an album review!! (id=".$file." now what? I haven't really added anything else to this yet"; } } ?> i know there's some extra code in there. I just want to get this working and then i'm gonna go back and clean everything up. Thanks. Link to comment https://forums.phpfreaks.com/topic/120532-xml-edit-not-editing-xml/#findComment-621182 Share on other sites More sharing options...
Zeradin Posted August 20, 2008 Author Share Posted August 20, 2008 bump =( Link to comment https://forums.phpfreaks.com/topic/120532-xml-edit-not-editing-xml/#findComment-621358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.