Jump to content

Database Not Updated


Deepzone

Recommended Posts

I have the following to update database but somehow it is doing so. Anyone has an idea? I added break point inside this function to check the parms passed in and they are correct.

 

function edit_book($book_id, $book_title) {

$conn = mysqli_connect('localhost', 'user', 'pwd', 'db') or die('Could Not Connect' . mysql_error());

$book_id = (int)$book_id;

$book_title = $conn->real_escape_string($book_title);

$stmt = $conn->stmt_init();

//***************** Break point - examine the value of book_id and book_title

if ($stmt->prepare("UPDATE book SET book_title=? WHERE book_id=?")) {

$stmt->bind_param('si', $parm_book_id, $parm_book_title);

$parm_book_id = $book_id;

$parm_book_title = $book_title;

$stmt->execute();

$stmt->close();

}

mysqli_close($conn);

}

Link to comment
https://forums.phpfreaks.com/topic/274797-database-not-updated/
Share on other sites

In reality you dont need $parm_book_id nor $ parm_book_title. .. you can use $ book_id and $ book_title directly in your bind sentence.

Also you cannot mix mysqli and mysql sentences..

Is that right? ... I've posted somehow to ask if mysql and mysqli can co-exist but most people said no. As I'm new in both, I greatly count on support from such forum. Thanks a lot.

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.