Deepzone Posted February 21, 2013 Share Posted February 21, 2013 (edited) 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 February 21, 2013 by Deepzone Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 21, 2013 Share Posted February 21, 2013 Without checking for mysql errors it's usually really hard to tell. But you don't have $parm_book_id defined or $parm_book_title. So... Quote Link to comment Share on other sites More sharing options...
Deepzone Posted February 21, 2013 Author Share Posted February 21, 2013 Without checking for mysql errors it's usually really hard to tell. But you don't have $parm_book_id defined or $parm_book_title. So... How am I be able to get the errors? Quote Link to comment Share on other sites More sharing options...
Barand Posted February 21, 2013 Share Posted February 21, 2013 $stmt->bind_param('si', $parm_book_id, $parm_book_title); I think you have the id and the title in the wrong order Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 21, 2013 Share Posted February 21, 2013 He's defining them AFTER trying to use them Quote Link to comment Share on other sites More sharing options...
Deepzone Posted February 22, 2013 Author Share Posted February 22, 2013 I think you have the id and the title in the wrong order Thank you. That's the problem. Quote Link to comment Share on other sites More sharing options...
Deepzone Posted February 22, 2013 Author Share Posted February 22, 2013 He's defining them AFTER trying to use them Sorry, I don't get it. Whats that mean? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 22, 2013 Share Posted February 22, 2013 (edited) Edit: God damnit. Edited February 22, 2013 by Jessica Quote Link to comment Share on other sites More sharing options...
mikosiko Posted February 22, 2013 Share Posted February 22, 2013 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.. Quote Link to comment Share on other sites More sharing options...
Deepzone Posted February 22, 2013 Author Share Posted February 22, 2013 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.