Jump to content

My update code is not updating the database with values


sonnieboy

Recommended Posts

<?php
  error_reporting(E_ERROR | E_WARNING | E_PARSE);

 // Initialize connection to database

$conn=mysqli_connect("localhost","myuser","mypass","mydb");

 // Check connection
 if (mysqli_connect_errno())
   {
   echo "Failed to connect to MySQL: " . mysqli_connect_error();
   }

function render_error($settings = array("title"=>"Failed","body"=>"Sorry, your submission failed. Please go back and fill out all required information."))
	{ ?>
<h2><?php echo (isset($settings['title']))? $settings['title']:"Error"; ?></h2>
<p><?php echo (isset($settings['body']))? $settings['body']:"An unknown error occurred."; ?></p>
<?php
	}
	$sql = "UPDATE xphias SET pastorname=?, ministriesname=?, sermon_name=?, scripture=?, video_name=?, sermon_notes=?, sermon_date=? WHERE sermon_id=?";

$stmt = $conn->prepare($sql);

// We have one datetime parameter, one integer parameter and 6 string data types
// So that's 6 consecutive string params and then 1 datetime parameter and one integer param.

$stmt->bind_param('sssssssd', $pastorname, $ministriesname, $sermon_name, $scripture, $video_name, $sermon_notes, $sermon_date, $sermon_id);
$stmt->execute();

if ($stmt->errno) {
  echo "FAILURE!!! " . $stmt->error;
}
else echo "Updated {$stmt->affected_rows} rows";

$stmt->close();

?>

Greetings again,

 

I am trying to use the following code to update some database fields.

 

When I run the code, I get successful update message but no record is updated.

 

I am not getting any errors.

 

Any ideas what I could be doing wrong?

 

 

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.