mysqli

Is is bad practice to use array_walk with mysqli_real_escape_string?

China☆狼群 提交于 2020-01-22 02:13:08
问题 So I have a function called "escape" that looks like this: function escape($string){ $escaped_string = mysqli_real_escape_string($this->conn, $string); return $escaped_string; } I before running a query I send a variable (originated from user input obviously) here so its escaped for security reasons. Now I know its possible to use array_walk to apply an array of values to this function, but I just want to know if there is any reason why I shouldn't? I know it sounds like a daft question but

SQL Joining query using Selection Statement

和自甴很熟 提交于 2020-01-21 22:12:48
问题 I have one table of oc_category_description where columns are : category_id name and other table oc_category where columns are : category_id image parent_id Here the sample pic of oc_category_description table oc_category table Here i am want to show name, category_id, image, parent_id where oc_category parent_id is 0; Here is sql : php function getMainCategory() { $stmt = $this->con->prepare("SELECT category_id, image, parent_id, (SELECT oc_category_description.name FROM oc_category

SQL Joining query using Selection Statement

半城伤御伤魂 提交于 2020-01-21 22:11:50
问题 I have one table of oc_category_description where columns are : category_id name and other table oc_category where columns are : category_id image parent_id Here the sample pic of oc_category_description table oc_category table Here i am want to show name, category_id, image, parent_id where oc_category parent_id is 0; Here is sql : php function getMainCategory() { $stmt = $this->con->prepare("SELECT category_id, image, parent_id, (SELECT oc_category_description.name FROM oc_category

Update Multiple Rows in one PHP

妖精的绣舞 提交于 2020-01-21 10:27:22
问题 I have three rows with three columns in one table id type value 1 gold 1000.00 2 silver 32.21 3 platinum 1500.00 I have a form on my page with three inputs to fill in the updated values and am using ajax to send those values to update_values.php The code below works, but I am curious as to whether there is a more efficient / proper way of doing this. Thanks in advance for the knowledge-boost! PHP //Pull data from settings update $gold=$_POST['gold']; $silver=$_POST['silver']; $plat=$_POST[

SQLi and retreiving a specific record

余生颓废 提交于 2020-01-21 10:24:37
问题 looked around, saw a lot of MySQL answers but not MySQLi.. Im attempting to return 1 line of my choosing. at the moment I can return only the first line. What im trying to get to is, have my main database be linked by ID, when you click the ID, a closer look at the record is on another page.. <?php $connect = mysqli_connect("localhost", "root", "", "mydb"); $query = "SELECT name, surname FROM info ORDER BY id"; $record = mysqli_query($connect, $query); @$num_results = mysqli_num_rows($record)

Insert Arabic data into mysql database

僤鯓⒐⒋嵵緔 提交于 2020-01-21 05:10:20
问题 i tried entering Arabic text and insert it into mysql database using php, when print the row, all rows that in arabic looks like : ???? ???? ???? ????? ابو نصير عمان الاردن الاردن بببببببببببببببببب i set my database to: Character set: utf8 -- UTF-8 Unicode Collation: utf8_general_ci and every field in database: Character set: utf8 Collation: utf8_general_ci i need to solve this problem and i appreciate all answers .. 回答1: Do the following: Include the

Insert multiple rows to database from HTML form using MySQLi

白昼怎懂夜的黑 提交于 2020-01-20 07:49:40
问题 I'm trying to make a form that uses arrays so once it is submitted and processed multiple rows get inserted into my database. My main program is more complex than below but I could not get it working so I decides to create a small simple program to understand the basic syntax better then apply the techniques to the main program. I have got it to work using the depreciated MySQL but converting it to MySQLi is causing problems that I wonder if I can get help with. My form is set up like this

Insert multiple rows to database from HTML form using MySQLi

我们两清 提交于 2020-01-20 07:48:33
问题 I'm trying to make a form that uses arrays so once it is submitted and processed multiple rows get inserted into my database. My main program is more complex than below but I could not get it working so I decides to create a small simple program to understand the basic syntax better then apply the techniques to the main program. I have got it to work using the depreciated MySQL but converting it to MySQLi is causing problems that I wonder if I can get help with. My form is set up like this

Call to undefined function mysqli_result::num_rows()

房东的猫 提交于 2020-01-19 01:48:45
问题 I'm trying to count the number of rows in a result, and I keep getting the above returned error. I've checked the manual, and I'm using mysqli_result::num_rows() as I should be (I'm using object oriented style.) I've got three classes working here. Class (Connection): class utils_MysqlImprovedConnection { protected $_connection; public function __construct($host, $user, $pwd, $db) { $this->_connection = @new mysqli($host, $user, $pwd, $db); if(mysqli_connect_errno ()) { throw new

Select the newest data in an SQL table? [closed]

只愿长相守 提交于 2020-01-17 16:32:52
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . I have a table for news and I want to select the 3 newest things in each row, they're numbered 1 as the oldest and each data I add it will be a number higher. So how do you get the three newest things and display the them in places? (Sorry I can't think of how to phrase my question) EDIT: I don't