Jump to content

php mysql update record not working ...help!!


azukah

Recommended Posts

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&quote=$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>

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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 />

Link to comment
Share on other sites

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.

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.