Deepzone Posted February 21, 2013 Share Posted February 21, 2013 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 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... Link to comment https://forums.phpfreaks.com/topic/274797-database-not-updated/#findComment-1414013 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? Link to comment https://forums.phpfreaks.com/topic/274797-database-not-updated/#findComment-1414014 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 Link to comment https://forums.phpfreaks.com/topic/274797-database-not-updated/#findComment-1414030 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 Link to comment https://forums.phpfreaks.com/topic/274797-database-not-updated/#findComment-1414033 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. Link to comment https://forums.phpfreaks.com/topic/274797-database-not-updated/#findComment-1414052 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? Link to comment https://forums.phpfreaks.com/topic/274797-database-not-updated/#findComment-1414053 Share on other sites More sharing options...
Jessica Posted February 22, 2013 Share Posted February 22, 2013 Edit: God damnit. Link to comment https://forums.phpfreaks.com/topic/274797-database-not-updated/#findComment-1414060 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.. Link to comment https://forums.phpfreaks.com/topic/274797-database-not-updated/#findComment-1414062 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. Link to comment https://forums.phpfreaks.com/topic/274797-database-not-updated/#findComment-1414066 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.