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>

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?

 

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

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.

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.