Jump to content

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);

}

Edited by Deepzone
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.
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.