mysqli

mysqli_select_db() expects parameter 1 to be mysqli, array given [duplicate]

廉价感情. 提交于 2020-01-07 08:37:07
问题 This question already has an answer here : Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in C:\ [duplicate] (1 answer) Closed 3 years ago . i need to to convert my project from MySQL to MySQLIi ,but i have problem in config file, please what is the error in my code? <?PHP $Db = array ( "hostname"=>"localhost", "dbname"=>"prstitodb", "dbuser"=>"root", "dbpass"=>"", ); $Dbconnect = mysqli_connect($Db['hostname'],$Db['dbuser'],$Db['dbpass']) or die(mysqli_error()); $DbSelect

MySql : SELECT COLUMNS WHERE COLUMNS VALUE ARE SAME

孤人 提交于 2020-01-07 08:24:29
问题 This is my table data.. column_1_____column_3_____column_4_____column_5_____column_6_____column_7_____column_8 yes no yes yes yes no yes here, their is only one datarow i want only that columns which has value = 'yes' . for this which query works? Thanks. 回答1: SQL is not organized around columns. It is organized around rows. You can do what you want with a query like this: select 'column1' as col from t where column1 = 'yes' union all select 'column2' as col from t where column2 = 'yes' union

mysqli database connection error when using functions from different files

筅森魡賤 提交于 2020-01-07 05:34:08
问题 I have a problem with the mysqli-connection not being open or used by functions which I include from other files. Look below at the setup. If I take all the code into one file, it works perfectly but in this way, nothing happens. connection.php <?php function connect() { $db = new mysqli("host", "user", "pswrd", "database"); return $db; } ?> functions.php <?php function get_user_email($user_id) { $sql = "SELECT email FROM user_acc WHERE user_id='$user_id'"; if(!$result = $db->query($sql))

Inserting multiple values using mysqli

蹲街弑〆低调 提交于 2020-01-07 03:53:06
问题 Can anybody tell me what is wrong with this line of code? I am currently new and now trying to use mysqli prepared statement in order to connect to the database back end. So far I can't seem to get it to update the database. $stmt = $mysqli->prepare("INSERT INTO canada VALUES (?,?,?,?,?,?)"); $stmt->bind_param('sssiss',$_REQUEST["UserID"],$_REQUEST["FirstName"], $_REQUEST["LastName"],$_REQUEST["Age"],$_REQUEST["WhatParty"], $_REQUEST["Electorate"]); $stmt->execute(); 回答1: The problem is the

MySQLi append more/deeper results

旧街凉风 提交于 2020-01-07 03:08:13
问题 I'm having the hardest time figuring this out and it's probably because I'm not using the correct terms. If someone could point me in the right direction, that would be amazing. I'm going to use a hypothetical situation to make things easier: I have a database with two tables: tableA contains records for a house sale (house ID,address, price, current owner ID, etc) tableB contains records for realtors who have shown a house (house ID, realtor ID, time and date, notes, etc). I would like to

PHP function to extract a field value from a database

强颜欢笑 提交于 2020-01-07 01:59:33
问题 I'm trying to get a value of a mysql database using a php function. I have a database like this: NAME | EMAIL | PASSWORD | OTHER ------------------------------------------------------- example | example@example.com | password | other ------------------------------------------------------- example2 | example2@example.com | password2 | other2 and in my PHP file I've tried to use this function: function selectUserField($email, $field, $connection){ $select_user = "SELECT '$field' FROM users

After login redirect to different page according to user role

大城市里の小女人 提交于 2020-01-06 20:07:25
问题 I would like to modify my code to redirect to different pages after login depending on user roles, I have only been able to make one universal redirect regardless of the role. I need help on how to implement that. Here is my db table of users: userID fullname email role password 1 Tester one test@gmail.com N ALSJALDDJ6464!JJLSK 2 Tester two tester@gmail.com C @ALSJAL5656DDJJJLSK My PHP login Code is here: <?php error_reporting(E_ALL ^ E_NOTICE); ini_set('display_errors', 1); // establishing

PHP keeps Inserting on refreshing

若如初见. 提交于 2020-01-06 19:57:27
问题 I am currently programming a website for a school project in which I have to organize daily schedules/reports. Following Situation: I am inserting the following into PHP: $sqlinserttb = "INSERT INTO tagesberichte (`TbID`, `Tagesberichte`, `Datum`) VALUES ('DEFAULT', '".$tagesbericht."', '".$datum."');"; If submit has been hit, it inserts it. The problem is when I press F5 or manually refresh the browser, the page inserts it again with the last used inputs. What did I miss? 回答1: Use header(

PHP keeps Inserting on refreshing

本小妞迷上赌 提交于 2020-01-06 19:55:09
问题 I am currently programming a website for a school project in which I have to organize daily schedules/reports. Following Situation: I am inserting the following into PHP: $sqlinserttb = "INSERT INTO tagesberichte (`TbID`, `Tagesberichte`, `Datum`) VALUES ('DEFAULT', '".$tagesbericht."', '".$datum."');"; If submit has been hit, it inserts it. The problem is when I press F5 or manually refresh the browser, the page inserts it again with the last used inputs. What did I miss? 回答1: Use header(

Compiling PHP with --enable-embedded-mysqli and --with-mysqli

瘦欲@ 提交于 2020-01-06 19:44:47
问题 Is there some difference between the two? I compiled my PHP 5.5.8 with the following: ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-pdo-mysql --with-gd --enable-embedded-mysqli --enable-zip --enable-mysqlnd --enable-cgi ... and later, in the installed PHP; I was receiving: call to undefined function mysqli_connect On looking at the PHP docs; I notice that the command is actually --with-mysqli But I was presented with the --enable-embedded-mysqli option on tab completion by bash