Riyoku Posted March 12, 2006 Share Posted March 12, 2006 Yes, me again, sorry ^^"Okay, mabey I've got the error retreival set up incorrectly? I don't know. What I do know is when I hit submit - the page claims it was successful. But when I go to retrieve the data later - it's completely unchanged. I've tried the code in the library but not only can I not.. understand it*so ashamed* but it causes HUGE strain on my website(at least I think it does, it takes about a minute to load a page right after I tried it) and gives me errors anyway... ._. So I switched back to the code I was using before.[code]mysql_query("UPDATE news SET `type`='$p_type', `title`='$p_title', `month`='$p_month', `day`='$p_day', `year`='$p_year', `body`='$p_body', `by`='$p_by' WHERE id='$n_id'") or die("<b>Update error : </b>". mysql_error());[/code]I can't post the error I'm getting as it wont give me one with that code. All I can say is I'm stumped that it just plain doesn't work... >>"Thanks again to the people who helped me last time. I learned my lesson, to set my pride aside and let people help - saves me a lot of time and frustration - and I can learn better that way too. Can't learn if I have no clue where I'm going wrong.EDIT - Sorry, I realised I left out a bit of information on my table and where the info is comming from. The table name is news and it has 8 rows; id(auto-number), type, title, month, day, year, body, and by. The new information is being retrieved by a form on the page. I'm only including the update statement as I'm assuming that's where the problem origonates. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 12, 2006 Share Posted March 12, 2006 Can you post some more of your code? One statement out of context is not a help.That being said, I would change your code to be:[code]<?php$q = "UPDATE news SET `type`='$p_type', `title`='$p_title', `month`='$p_month', `day`='$p_day', `year`='$p_year', `body`='$p_body', `by`='$p_by' WHERE id='$n_id'";echo '<pre> Query: ' . $q . '</pre><br />'; // for debugging$rs = mysql_query($q) or die('Problem with query: ' . $q . '<br />' . mysql_error());?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
Riyoku Posted March 12, 2006 Author Share Posted March 12, 2006 [!--quoteo(post=354257:date=Mar 12 2006, 02:09 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 12 2006, 02:09 PM) [snapback]354257[/snapback][/div][div class=\'quotemain\'][!--quotec--]Can you post some more of your code? One statement out of context is not a help.That being said, I would change your code to be:[code]<?php$q = "UPDATE news SET `type`='$p_type', `title`='$p_title', `month`='$p_month', `day`='$p_day', `year`='$p_year', `body`='$p_body', `by`='$p_by' WHERE id='$n_id'";echo '<pre> Query: ' . $q . '</pre><br />'; // for debugging$rs = mysql_query($q) or die('Problem with query: ' . $q . '<br />' . mysql_error());?>[/code]Ken[/quote]Oh, I'm sorry. I thought my problem was with just that statement so I didn't include more... [code]<?php include "db.php";$n_id = $_GET['id'];$result=mysql_query("SELECT * FROM news WHERE id='$n_id'")or die("<b>Query error : </b>". mysql_error());if (($REQUEST_METHOD=='POST')) {$p_type = $_POST['p_type'];$p_title = $_POST['p_title'];$p_month = $_POST['p_month'];$p_day = $_POST['p_day'];$p_year = $_POST['p_year'];$p_body = $_POST['p_body'];$p_by = $_POST['p_by'];$q = "UPDATE news SET `type`='$p_type', `title`='$p_title', `month`='$p_month', `day`='$p_day', `year`='$p_year', `body`='$p_body', `by`='$p_by' WHERE id='$n_id'";echo '<pre> Query: ' . $q . '</pre><br />'; // for debugging$rs = mysql_query($q) or die('Problem with query: ' . $q . '<br>' . mysql_error());}else {while($row = mysql_fetch_array( $result )) {$f_type = $row['type'];$f_title = $row['title'];$f_month = $row['month'];$f_day = $row['day'];$f_year = $row['year'];$f_body = $row['body'];$f_by = $row['by'];?><!--FORM--><form action="nedt.php" method="post"><table align="center"><tr><td><b>Type</b></td><td><select style="width:188" name="p_type"> <option value="news">News</option> <option value="updt">Update</option> <option value="rmnr">Reminder</option></select></td></tr><tr><td><b>Title</b></td><td><input type="text" style="width:188" name="p_title" value="<?echo $f_title;?>"></td></tr><tr><td><b>Date</b></td> <td><input type="text" style="width:60" name="p_month" value="<?echo $f_month;?>"> <input type="text" style="width:60" name="p_day" value="<?echo $f_day;?>"> <input type="text" style="width:60" name="p_year" value="<?echo $f_year;?>"></td></tr><tr><td colspan=2><textarea style="width:226" name="p_body"><?echo $f_body;?></textarea></td></tr><tr><td><b>Sign</b></td><td><input type="text" style="width:188" name="p_by" value="<?echo $f_by;?>"></td></tr><tr><td colspan=2 align="right"><input type="submit" value="Submit"><input type="reset" value="Reset"></td></tr></table></form><? }} ?>[/code]It's retrieving the info from a form on the same page :PEDIT - added the whole thing just to be sure... and I THINK I figured out the problem thanks to your error retrieval - it isn't passing the ID along with the form! [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Query: UPDATE news SET `type`='news', `title`='Test', `month`='01', `day`='01', `year`='06', `body`='blah blah', `by`='Riyoku' WHERE id=''[/quote]would a hidden field do it?EDIT AGAIN - Apparently, it would! WOOOOOO! Thank you again for your help! Without your input, I would have never figured out where I went wrong. :3 *finishes up her pages now that she's got all the functions figured out. X3* <3 Quote Link to comment Share on other sites More sharing options...
comicrebel Posted August 13, 2008 Share Posted August 13, 2008 Thanks to this error reporting code, (and after HOURS of would be debugging) I was also able to identify the problem quickly (I wasn't defining my variables-duh)$result = mysql_query($sql) or die('Problem with query: ' . $sql . '<br />' . mysql_error());Thank you Riyoku! Quote Link to comment Share on other sites More sharing options...
dezkit Posted August 13, 2008 Share Posted August 13, 2008 SORRY FOR GETTING OFF TOPIC BUT HOW DOES THIS THREAD HAVE 1000 VIEWS? LOL Quote Link to comment 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.