azukah Posted August 14, 2010 Share Posted August 14, 2010 hi - i'm trying to update mysql databse but not working... any ideas??? [code=php:0] <?php ob_start(); require_once('../xconfig.php'); if(isset ($_GET['quote'])&& $_GET['quote']!=""){ $quote_id=$_GET['quote']; mysql_select_db($database, $makeconnection); $sql_find_quote = "SELECT * FROM tbl_quote WHERE quote_id = $quote_id"; $find_quote = mysql_query($sql_find_quote, $makeconnection) or die(mysql_error()); $row = mysql_fetch_assoc($find_quote); $totalRows = mysql_num_rows($find_quote); $quote_author = $_POST['quote_author']; $quote_desc = $_POST['quote_desc']; if (isset($_POST['submitted'])&&($_POST['submitted'] == "yes")) { $register_query = "SELECT quote_desc FROM tbl_quote WHERE quote_desc='$quote_desc'"; mysql_select_db($database, $makeconnection); $register_check=mysql_query($register_query, $makeconnection); $register_found_quote = mysql_num_rows($register_check); if($register_found_quote>1){ header ("Location: quote_modify.php?error=quoteexists"e=$quote_id"); }else{ $sql_modify = "UPDATE tbl_quote SET quote_desc = '$quote_desc' quote_author = '$quote_author' WHERE quote_id = '$quote_id'"; } mysql_select_db($database, $makeconnection); $Result1 = mysql_query($sql_modify, $makeconnection) or die(mysql_error()); header ("Location: quote.php"); } } ob_flush(); ?> [/code] here's my HTML form <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <p> <input name="quote_author" type="text" class="active-field" id="quote_author" value="<? echo $row['quote_author'];?>"/> <br /> <input name="quote_desc" type="text" class="active-field" id="quote_desc" value="<? echo $row['quote_desc'];?>" /> <br /> <input name="submitted" type="hidden" id="submitted" value="yes" /> <input name="submit" type="submit" id="submit" class="submit-button" value="modiy"/> <br /> </p> </form> Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 14, 2010 Share Posted August 14, 2010 if(isset ($_GET['quote'])&& $_GET['quote']!=""){ $quote_id=$_GET['quote']; Where is this value getting set at? I don't see it in the form... add this to the top after your <?php open tag: error_reporting(E_ALL); What errors does it display? Quote Link to comment Share on other sites More sharing options...
azukah Posted August 14, 2010 Author Share Posted August 14, 2010 i get errors n the value fields in the form (where i'm echoing) <br /> <b>Notice</b>: Undefined variable: row in <b>/hermes/web03/b443/moo.azukah/project_dorimingu/cms/cms_quote/quote_modify.php</b> on line <b>70</b><br /> <br /> <b>Notice</b>: Undefined variable: row in <b>/hermes/web03/b443/moo.azukah/project_dorimingu/cms/cms_quote/quote_modify.php</b> on line <b>72</b><br /> Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 14, 2010 Share Posted August 14, 2010 if(isset ($_GET['quote'])&& $_GET['quote']!=""){ $quote_id=$_GET['quote']; mysql_select_db($database, $makeconnection); $sql_find_quote = "SELECT * FROM tbl_quote WHERE quote_id = $quote_id"; $find_quote = mysql_query($sql_find_quote, $makeconnection) or die(mysql_error()); $row = mysql_fetch_assoc($find_quote); In this portion of your code your using $_GET['quote']; but where is that set at? I don't see any value in your form for this. Also usually you assign the $_POST variables after the submitted form: if (isset($_POST['submitted'])&&($_POST['submitted'] == "yes")) { $quote_author = $_POST['quote_author']; $quote_desc = $_POST['quote_desc']; I would recommend escaping the input's also. Quote Link to comment Share on other sites More sharing options...
azukah Posted August 14, 2010 Author Share Posted August 14, 2010 you are right . I missed it. i'm GETting 'quote' from another page and i misspelled it - thanks !!! Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 14, 2010 Share Posted August 14, 2010 Yw, I'm glad it's working for ya now. 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.