mysqli

How to insert/create stored procedures in mySQL from PHP?

China☆狼群 提交于 2020-01-10 19:43:26
问题 I've got a number of stored procedures made with the MySQL Workbench. They work just fine when use MySQL workbench to put them into my test DB. Now I am preparing the DB creation scripts for deployment, and this is the only one giving me trouble. When I use the command line / mysql shell, the script works perfectly well to. It's only when I use the PHP mysql(i) interface to execute the script - it fails. Without comment. I use the procedure creation scripts as MySQL workbench generates for me

alternative to mysql_field_name in mysqli

那年仲夏 提交于 2020-01-10 19:27:25
问题 So I found this great function that converts mysql queries into a XML page, and it looks like exactly what I need. The only problem is that it uses mysql, but thats not supported anymore, and it turns out one of the functions used isn't in mysqli. Does anyone know of an alternative to mysql_field_name? Here's the function that I found function sqlToXml($queryResult, $rootElementName, $childElementName) { $xmlData = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"; $xmlData .= "<" .

MYSQLi bind_result is returning null

你说的曾经没有我的故事 提交于 2020-01-10 05:34:26
问题 I am trying to output the variables that I get from the database in my query but nothing is being returned. Using MYSQLi prepared statements. Please see code below: $stmt = $con->prepare("SELECT first_name, last_name FROM transactions WHERE order_id = ?"); $stmt->bind_param('i', $order_id); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($first_name, $last_name); $stmt->close(); // Output review live to page echo $first_name; I cannot see where I am going wrong? PS I am new to

Get all objects without loop in OOP MySQLi

别说谁变了你拦得住时间么 提交于 2020-01-10 05:06:42
问题 This is how I get one record with MySQLi: $result = $db->query("..."); $image = $result->fetch_object(); Now I need to get the comments and pass it to the view. I'm doing this right now but it doesn't seem right: $result = $db->query("..."); while ($row = $result->fetch_object()) $comments[] = $row; I'm wondering if there's a way to remove the loop? Something like have $image = $result->fetch_object(((s))), so my code would look like: $result = $db->query("..."); $comments = $result->fetch

How to use MySQLi Driver in Codeigniter

假如想象 提交于 2020-01-10 02:50:11
问题 Hi I'm kinda new to this and I would like to ask someone here that are experts in codeigniter framework and PHP. How can I use mysqli drivers in php native query? For example. My code: Model class Home_model extends CI_Model{ public function getusers(){ $q = "SELECT * FROM `users`"; return $r = mysqli_query($q); } } Controller: class Home extends CI_Controller{ public function iterateuser(){ while($row = mysqli_fetch_object($this->Home_model->getusers())){ echo $row->username; } } My code

Having trouble executing a SELECT query in a prepared statement

梦想的初衷 提交于 2020-01-09 18:34:06
问题 Ive followed a bunch of different examples regarding using a SELECT in a prepared statement, but nothing is returned. EDIT I have changed my code a bit to look like this: $date1 = 2012-01-01; $date2 = 2012-01-31; $sql_con = new mysqli('db', 'username', 'password', 'database'); if($stmt = $sql_con->prepare("SELECT eventLogID FROM Country WHERE countryCode=? AND date BETWEEN ? AND ?")){ $stmt->bind_param("sss", $country_code, $date1,$date2); $stmt->execute(); $i=0; while ($stmt->fetch()){ $stmt

Are PHP MySQLi prepared queries with bound parameters secure?

 ̄綄美尐妖づ 提交于 2020-01-09 10:51:25
问题 Historically, I've always used mysql_real_escape_string() for all input derived from users that ends up touching the database. Now that I've completely converted over to MySQLi and I'm using prepared queries with bound parameters, have I effectively eliminated the possibility of SQL injection attacks? Am I correct in saying I no longer need mysql_real_escape_string()? This is my understanding and the basis of a project of mine: http://sourceforge.net/projects/mysqldoneright/files/Base

Are PHP MySQLi prepared queries with bound parameters secure?

爱⌒轻易说出口 提交于 2020-01-09 10:50:54
问题 Historically, I've always used mysql_real_escape_string() for all input derived from users that ends up touching the database. Now that I've completely converted over to MySQLi and I'm using prepared queries with bound parameters, have I effectively eliminated the possibility of SQL injection attacks? Am I correct in saying I no longer need mysql_real_escape_string()? This is my understanding and the basis of a project of mine: http://sourceforge.net/projects/mysqldoneright/files/Base

Fatal error: Call to undefined function mysqli_result()

我只是一个虾纸丫 提交于 2020-01-08 14:36:01
问题 Can someone please tell me why this doesnt work, when I tried to switch my old sql to sqli: $query = "SELECT * FROM `product_category`"; $result = mysql_query($query, $connect) or die("could not perform query: " . mysql_error()); $num_rows = mysql_num_rows($result); for ($i=0; $i < $num_rows; $i++) { $ID = mysql_result($result,$i,"ID"); $name = mysql_result($result,$i,"name"); $description = mysql_result($result,$i,"description"); to: $query = ("SELECT * FROM `product_category`"); $result =

MySQL vs MySQLi when using PHP [closed]

淺唱寂寞╮ 提交于 2020-01-08 08:45:30
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Which is better, MySQL or MySQLi? And why? Which should I use? I mean better not just in terms of performance, but any other relevant