mysqli

MYSQLi store result and then get result

拟墨画扇 提交于 2020-05-02 05:00:13
问题 I have a function which does the following things $stmt = mysqli_prepare.. //check for preparation failure mysqli_stmt_bind_param //Check for bind error mysqli_stmt_execute //Check for execution error mysqli_stmt_store_result //Problem is here //Check for error return $stmt I have these steps in a function because I need it in two placeds the same piece of code. After getting the stmt, I need to check number of rows [ mysqli_Stmt_num_rows ]. So only I have that stored result stmt at the end

Use PHP to Update a Value in a MySQLi Database Table

≡放荡痞女 提交于 2020-04-30 12:20:19
问题 I've written the below function to update a value in a MySQLi database table. I'm not receiving any errors, but the value is also not updating. I can't see what's going wrong. function update_hangman_highscore($user, $user_highscore){ echo 'Update highscore called. High score to update is '.$user_highscore.' for '.$user; $db = "localhost"; $user = "phpuser"; $pwd = "Ninja1995"; $database = "ninja_comments"; $link = mysqli_connect($db, $user, $pwd)or die(mysqli_connect_error()); mysqli_select

Check if username exist/activated in database using MYSQLi [duplicate]

走远了吗. 提交于 2020-04-18 06:00:06
问题 This question already has an answer here : Check to see if an email is already in the database using prepared statements (1 answer) Closed last month . $username = mysqli_real_escape_string($_POST['username']); $result = mysqli_query($connect, "SELECT * FROM account WHERE username='".$username."' AND activate='0'"); while($row = mysqli_fetch_assoc($result)) { echo 'Account not activated.'; } I'm new to MYSQLi and I need help on how do I show an error if the user enter a wrong username and its

PHP MySQL INSERT not inserting nor any error is displayed

☆樱花仙子☆ 提交于 2020-04-12 21:54:27
问题 I have got this code so insert values into a table in MySQL through PHP. I have tried all the possible Insert syntax, it does not insert the data... this are the codes that i used. $param = "xyzxyz"; $param1 = "sdfdfg"; $sql = "INSERT INTO trail (User_Name, Quiz_ID) VALUES ('".$param."','".$param1."')"; $result = $mysql->query($sql); if($result) echo "successful"; else echo mysql->error; if(mysql->errno==0) echo "successful" else echo mysql->error; I even tried the following sql syntax

PHP MySQL INSERT not inserting nor any error is displayed

本小妞迷上赌 提交于 2020-04-12 21:53:32
问题 I have got this code so insert values into a table in MySQL through PHP. I have tried all the possible Insert syntax, it does not insert the data... this are the codes that i used. $param = "xyzxyz"; $param1 = "sdfdfg"; $sql = "INSERT INTO trail (User_Name, Quiz_ID) VALUES ('".$param."','".$param1."')"; $result = $mysql->query($sql); if($result) echo "successful"; else echo mysql->error; if(mysql->errno==0) echo "successful" else echo mysql->error; I even tried the following sql syntax

So I am trying to create an login system on my localhost server with xampp and but my sql query is not running [duplicate]

早过忘川 提交于 2020-04-07 10:44:15
问题 This question already has answers here : mysqli_fetch_assoc() expects parameter / Call to a member function bind_param() errors. How to get the actual mysql error and fix it? (1 answer) Reference - What does this error mean in PHP? (36 answers) How to use PHP's password_hash to hash and verify passwords (7 answers) Closed 23 days ago . I am trying to make a loginsystem with localhost server in xampp and phpmyadmin but the mysqli statement is somehow showing error. Ps I am new to this, So if

How to install MySQLi

南笙酒味 提交于 2020-04-07 10:38:28
问题 I cannot find instructions about installing MySQLi on a Mac. Just to be clear, MySQL is up to date and I am running PHP 5. How do I install it? Where do I even get it from? Thanks for your help. I'll be giving an up vote and a check mark to whoever answers this! 回答1: MySQLi is part of PHP. There should be a php-mysqli type package available, or you can take the PHP source and recompile that mysqli enabled. You may already have it installed, but it's done as a module and is disabled. Check

mysql to mysqli change [duplicate]

孤街醉人 提交于 2020-04-07 08:05:03
问题 This question already has answers here : How to change mysql to mysqli? (12 answers) Closed 16 hours ago . who can help me turn this code into mysqli? Ho tentato più soluzioni ma nn riesco a trasformarlo. THX function GetFilesById($Id){ $query = "SELECT * FROM allegati where id=$Id"; $result = mysql_query($query); $data = MYSQL_RESULT($result,0,"data"); $type = MYSQL_RESULT($result,0,"filetype"); $name = MYSQL_RESULT($result,0,"filename"); $myFile = array("data" => $data, "type" => $type,

Complex php mysqli query to insert data if not exist: getting Duplicate column name '?'

ε祈祈猫儿з 提交于 2020-04-07 05:54:08
问题 So guys, please review this sample code of me, and help me , i cannot find the solution , keep getting Duplicate column name on the line where I passed parameters like ?,?,?,? . I passed 7 variables all together in the query. Any idea what can be the problem? $SQL = "INSERT INTO wifi (ssid, password, name, surname) SELECT * FROM(SELECT ?, ?, ?, ?) AS tmp WHERE NOT EXISTS (SELECT ssid,name,surname FROM wifi WHERE ssid=? AND name=? AND surname=?) LIMIT 1;"; if ($stmt = $mysqli->prepare($SQL)) {

PHP MySQLi is just returning one row in JSON

|▌冷眼眸甩不掉的悲伤 提交于 2020-04-07 05:13:25
问题 I am working on the below code. Why am I getting only one row in my JSON output? $items = []; if ($stmt = $this->conn->prepare("SELECT * FROM $tbl")) { $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $items = $row; } $stmt->free_result(); $stmt->close(); } $this->conn->close(); } echo json_encode($items); 回答1: This happens because you are going through the rows and assigning each of them to $items : while ($row = $result-