mysqli

mysqli_insert_id() is returning 0 but inserting the data

北城以北 提交于 2020-07-15 10:00:09
问题 The Code is : class anything_i { /*Every variable is defined and hidden fro privacy.*/ public function connect(){ return mysqli_connect(self::HOST,self::USERNAME,self::PASSWORD,self::DATBASE); } public function insertData($postData){ $sqli = 'INSERT INTO `payments`(`item_name`,`price`,`email`,`date`,`time`,`detail`,`volume`,`ip`,`payment_status`) VALUES ("'.$productData['name'].'","'.$productData['price'].'","'.$postData['email'].'","'.$date.'","'.$time.'","'.$postData['list'].'","'.

MySQLi not found dockerized php

丶灬走出姿态 提交于 2020-07-15 04:34:20
问题 I'm trying to dockerize my website. I've got Nginx and PHP up and running and it's working find except I can't connect to a db. When the page is loaded I get the error: Fatal error: Uncaught Error: Class 'MySQLi' not found in /private/conn.php:8 Stack trace: #0 /public_html/index.php(2): require() #1 {main} thrown in /private/conn.php on line 8 My connection line on line 8 is: $db = new mysqli("$host", "$user", "$pass", "$db", "$port"); Now this used to work fine on my old set up but since

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given on line 6 [duplicate]

假装没事ソ 提交于 2020-07-10 17:29:46
问题 This question already has answers here : Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in (2 answers) Closed 4 years ago . <?php if (isset($_GET['hash'])&&!empty($_GET['hash'])){ $hash = $_GET['hash']; $message_query = "SELECT from_id, message FROM message WHERE hash='$hash'"; $run_messages = mysqli_query($con,$message_query); while($row_messages = mysqli_fetch_array($con,$run_messages)){ $form_id = $row_messages['from_id']; $message = $row_messages[

PHP MYSQL updating multiple rows using values from an array

感情迁移 提交于 2020-07-10 11:52:20
问题 I've working on this problem for a while, and I've been stuck for a few days. What I have is a basic blog system, and right now I'm stuck on trying to delete/hide posts from a list. if(isset($_POST['hideBtn']) && isset($_POST['hidePost'])){ $checked = $_POST['hidePost']; print_r($checked); } elseif(isset($_POST['hideBtn']) && !isset($_POST['hidePost'])){ echo "Nothing Selected"; } There is a checkbox for each post that shows up in the list. <input type="checkbox" name="hidePost[]" value="<

PHP MYSQL updating multiple rows using values from an array

本秂侑毒 提交于 2020-07-10 11:48:01
问题 I've working on this problem for a while, and I've been stuck for a few days. What I have is a basic blog system, and right now I'm stuck on trying to delete/hide posts from a list. if(isset($_POST['hideBtn']) && isset($_POST['hidePost'])){ $checked = $_POST['hidePost']; print_r($checked); } elseif(isset($_POST['hideBtn']) && !isset($_POST['hidePost'])){ echo "Nothing Selected"; } There is a checkbox for each post that shows up in the list. <input type="checkbox" name="hidePost[]" value="<

Can't use more than one STMT query for mysqli

末鹿安然 提交于 2020-07-04 04:23:49
问题 I'm trying to generate an users creation page and I make a validation to determine if the user already exists, for that I use the next code: here i insert the user and his password to the table USERS mysqli_stmt_bind_param($guardar_usuario, 'ss', $usuario,$encriptar); mysqli_stmt_execute($guardar_usuario); here i reuse the variable $user to recover the new id user created $consulta = "SELECT id_usuario FROM usuario WHERE usuario = '$usuario' ORDER BY fecha_registro DESC LIMIT 1"; $ultimo

Which is better way for write PHP code for insert data

橙三吉。 提交于 2020-07-03 13:25:17
问题 I am some confused because some people write PHP code like this for upload data. But my instructor used $query and $link always to upload and retrieve data from SQL. <?php include 'connection.php'; function reg_in() { if (isset($_POST['submit'])) { $name = $_POST['name']; $email = $_POST['email']; $mob = $_POST['mobile']; $check_in = $_POST['in']; $check_out = $_POST['out']; $rm = $_POST['room']; $room_type = $_POST['type']; // Problem start from here if (mysql_query("INSERT INTO `book` (

mysqli_insert_id () [duplicate]

℡╲_俬逩灬. 提交于 2020-07-03 08:14:09
问题 This question already has answers here : mysqli_insert_id: What if someone inserts another row just before I call this? (2 answers) Closed 3 years ago . is it safe to use mysqli_insert_id() when the database is heavily used and more than one id maybe inserted in the same time, or it will get only the id that inserted by a query from this user.. 回答1: mysqli_insert_id() is specific to the database connection , it returns the ID of the row which you inserted most recently. 来源: https:/

Preserve line breaks in mysqli fetch_assoc( ) PHP

喜夏-厌秋 提交于 2020-07-03 06:34:14
问题 I am trying to get all the rows from my MySQL database using the following code: $sql = "SELECT * FROM myTable"; $result = $conn->query($sql); while($row = $result->fetch_assoc()) { $output[]=$row; } echo json_encode($output); My question is, How to preserve the line breaks using this code? I can preserve line breaks using nl2br() when I need a particular string for example nl2br($_row['fieldName']); but I want to know How can I use the same nl2br() when fetching the result in an array? I

Preserve line breaks in mysqli fetch_assoc( ) PHP

强颜欢笑 提交于 2020-07-03 06:31:23
问题 I am trying to get all the rows from my MySQL database using the following code: $sql = "SELECT * FROM myTable"; $result = $conn->query($sql); while($row = $result->fetch_assoc()) { $output[]=$row; } echo json_encode($output); My question is, How to preserve the line breaks using this code? I can preserve line breaks using nl2br() when I need a particular string for example nl2br($_row['fieldName']); but I want to know How can I use the same nl2br() when fetching the result in an array? I