mysqli

Difference between mysql & mysqli [duplicate]

百般思念 提交于 2019-12-28 06:17:11
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: mysql vs mysqli in php What is the difference between mysql_* functions and mysqli_* functions ? Is there any technical reasons behind we shouldn't use mysql_* functions ? 回答1: The "i" stands for "improved". The list of improvements can be found in here. MySQLi is the OOP version of MySQL extension. In the end, MySQLi and MySQL accomplish the same thing: they are extension for interacting with MySQL from PHP. A

mysqli + xdebug breakpoint after closing statement result in many warnings

£可爱£侵袭症+ 提交于 2019-12-28 05:49:06
问题 I have a piece of code like this: $conn = new mysqli($host, $username, $passwd, $dbname); ... $stmt = $conn->prepare('SELECT ...'); $stmt->bind_param(...); $stmt->execute(); $stmt->bind_result(...); while($stmt->fetch()) { // do something here } $stmt->close(); ... // do something more here that has absolutely nothing to do with $stmt This works perfectly fine. I get the results I expected, there are no errors or anything that is not supposed to happen. But if I set a break point (Xdebug 2.2

mysqli_prepare vs PDO

夙愿已清 提交于 2019-12-28 03:15:05
问题 BACKGROUND I'm trying to write a function query query('type', 'parameters', 'bind_types') which I can call to make simple queries. All the mySQL queries are in the function grab_sql() All the binding takes place in the function bind() call_user_func_array needs references to function correctly so I wrote ref_arr to accomodate. Problem is that I'm not getting the results back that I need - they are posted below under results. I think the issue is in the binding of the reuslts as I kind of

Fatal error: Call to undefined method mysqli_result::fetch_all()

大兔子大兔子 提交于 2019-12-28 03:04:50
问题 I have problems with PHP in Ubuntu 10.04. When I try use mysqli_result::fetch_all this error appears: Call to undefined method mysqli_result::fetch_all() However, it works in Windows XP. The Code: $result = $this->dbh->query('SELECT [...] '); return $result->fetch_all(MYSQLI_ASSOC); I don't want to use fetch_assoc with a loop because I send the result to another layer for processing. I'm using PHP 5.4.4. and with php -m | grep mysql the mysqlnd module it doesn't appear. How can I install it?

php password_verify not working with database

时间秒杀一切 提交于 2019-12-28 00:51:13
问题 I am using php 5.4 with this backwards compatibility script: https://github.com/ircmaxell/password_compat/blob/master/lib/password.php that shouldn't matter though, because I can get the hashing and verification process working in my registration function: $hash = password_hash($pass, PASSWORD_DEFAULT); echo $pass; echo $hash; if( password_verify($pass,$hash) ) echo 'success'; else echo 'failure'; //success is always shown //EXAMPLE INPUT $pass = 'password'; //EXAMPLE OUTPUT password$2y$10

How to get count of rows in MySQL table using PHP?

徘徊边缘 提交于 2019-12-27 17:56:13
问题 I simply want to use PHP to get a count of the total number of rows in a MySQL table, and store the number in a variable called $count . I prefer procedural code since my mind doesn't work in object-oriented fashion. $sql="SELECT COUNT(*) FROM news"; $result = mysqli_query($con, $sql); $count = mysqli_fetch_assoc($result); echo $count; The above is the latest I tried. Instead of giving me a number, it gives me the word "Array". 回答1: You have a couple of options how to get the value of COUNT(*

How to get count of rows in MySQL table using PHP?

*爱你&永不变心* 提交于 2019-12-27 17:56:03
问题 I simply want to use PHP to get a count of the total number of rows in a MySQL table, and store the number in a variable called $count . I prefer procedural code since my mind doesn't work in object-oriented fashion. $sql="SELECT COUNT(*) FROM news"; $result = mysqli_query($con, $sql); $count = mysqli_fetch_assoc($result); echo $count; The above is the latest I tried. Instead of giving me a number, it gives me the word "Array". 回答1: You have a couple of options how to get the value of COUNT(*

MySQLi Bind Param with an array for IN

不问归期 提交于 2019-12-27 12:29:57
问题 I am trying to pass an array to $stmt->bind_param for as an IN variable. How can I do this? $values = array('a','b','c','d'); $values = '"' . implode('","', $values) . '"'; $stmt->prepare('SELECT value1, value2 FROM table1 WHERE value3 IN (?)'); $stmt->bind_param('s', $values); I can't get it to work for the life of me. Any thoughts? The above code is just a sample. 回答1: This is a scenario where doing it this way is inappropriate. You're constructing actual SQL (that's what the commas and

How to echo a MySQLi prepared statement?

社会主义新天地 提交于 2019-12-27 11:48:50
问题 I'm playing around with MySQLi at the moment, trying to figure out how it all works. In my current projects I always like to echo out a query string while coding, just to make sure that everything is correct, and to quickly debug my code. But... how can I do this with a prepared MySQLi statement? Example: $id = 1; $baz = 'something'; if ($stmt = $mysqli->prepare("SELECT foo FROM bar WHERE id=? AND baz=?")) { $stmt->bind_param('is',$id,$baz); // how to preview this prepared query before

How to echo a MySQLi prepared statement?

别来无恙 提交于 2019-12-27 11:46:49
问题 I'm playing around with MySQLi at the moment, trying to figure out how it all works. In my current projects I always like to echo out a query string while coding, just to make sure that everything is correct, and to quickly debug my code. But... how can I do this with a prepared MySQLi statement? Example: $id = 1; $baz = 'something'; if ($stmt = $mysqli->prepare("SELECT foo FROM bar WHERE id=? AND baz=?")) { $stmt->bind_param('is',$id,$baz); // how to preview this prepared query before