mysqli

mysqli query results to show all rows

好久不见. 提交于 2019-12-27 11:35:45
问题 I have the following code: include $_SERVER['DOCUMENT_ROOT'].'/include/conn.php'; $query = "SELECT title FROM news_event"; $result = $mysqli->query($query); $row = $result->fetch_array(MYSQLI_BOTH); $row_cnt = $result->num_rows; $result->free(); $mysqli->close(); This is fine if there is only one result as I can just echo $row['title'] but if there are lots of results, how do I get this to loop through and print every row? I'm sure this is really simple but I'm just not sure what I need to

Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in C:\ [duplicate]

血红的双手。 提交于 2019-12-27 11:32:20
问题 This question already has answers here : Warning: mysqli_query() expects at least 2 parameters, 1 given. What? [duplicate] (2 answers) Closed 5 years ago . I'm doing a tutorial in which the author has not updated his content to reflect changes in the PHP documentation. Anyways, I need to know what is parameter is being asked of me to provide. I've checked that all things are in order, but I literally don't know what I'm supposed to provide. Here's what I have: Connects.php <?php $connect

mysqli query results to show all rows

吃可爱长大的小学妹 提交于 2019-12-27 11:32:12
问题 I have the following code: include $_SERVER['DOCUMENT_ROOT'].'/include/conn.php'; $query = "SELECT title FROM news_event"; $result = $mysqli->query($query); $row = $result->fetch_array(MYSQLI_BOTH); $row_cnt = $result->num_rows; $result->free(); $mysqli->close(); This is fine if there is only one result as I can just echo $row['title'] but if there are lots of results, how do I get this to loop through and print every row? I'm sure this is really simple but I'm just not sure what I need to

mysqli query results to show all rows

安稳与你 提交于 2019-12-27 11:32:07
问题 I have the following code: include $_SERVER['DOCUMENT_ROOT'].'/include/conn.php'; $query = "SELECT title FROM news_event"; $result = $mysqli->query($query); $row = $result->fetch_array(MYSQLI_BOTH); $row_cnt = $result->num_rows; $result->free(); $mysqli->close(); This is fine if there is only one result as I can just echo $row['title'] but if there are lots of results, how do I get this to loop through and print every row? I'm sure this is really simple but I'm just not sure what I need to

Myqli php login

牧云@^-^@ 提交于 2019-12-27 01:20:29
问题 I have just started using mysqli I'm trying to connect to a database and login, I'm getting the error messages, Notice: Undefined index: ___mysqli_ston in E:\EasyPHP-DevServer-14.1VC11\data\localweb\my portable files\course work\login.php on line 14 I'm also trying to display error messages on the page of the form rather than creating a new page which it's currently doing. I forget does the PHP have to be on the same page for the errors to be displayed? Warning: mysqli_query() expects

Can I improve my PDO method (just started)

馋奶兔 提交于 2019-12-26 15:07:55
问题 I just switched to PDO from mySQLi (from mySQL) and it's so far good and easy, especially regarding prepared statements This is what I have for a select with prepared statement Main DB file (included in all pages): class DBi { public static $conn; // this I need to make the connection "global" } try { DBi::$conn = new PDO("mysql:host=$dbhost;dbname=$dbname;charset=utf8", $dbuname, $dbpass); DBi::$conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); DBi::$conn->setAttribute(PDO:

Can I improve my PDO method (just started)

放肆的年华 提交于 2019-12-26 15:06:02
问题 I just switched to PDO from mySQLi (from mySQL) and it's so far good and easy, especially regarding prepared statements This is what I have for a select with prepared statement Main DB file (included in all pages): class DBi { public static $conn; // this I need to make the connection "global" } try { DBi::$conn = new PDO("mysql:host=$dbhost;dbname=$dbname;charset=utf8", $dbuname, $dbpass); DBi::$conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); DBi::$conn->setAttribute(PDO:

MySQL to MySQLi connection problems

假装没事ソ 提交于 2019-12-26 14:46:09
问题 I recently upgraded my server and now I'm trying to convert everything from MySQL to MySQLi and I'm having some difficulty. I keep getting this error: PHP Warning: mysqli_select_db() expects exactly 2 parameters Can someone guide me in the right direction please and thanks!!! Here is my old code that is in a PHP class: class Db { function __construct($app = ''){ // Get the main settings from the array we just loaded $host = 'localhost'; $user = 'username'; $pass = 'password'; $db = 'db_name';

mysqli warnings appearing when creating dynamic WHERE clause

偶尔善良 提交于 2019-12-25 21:05:37
问题 I am trying to create a query with a dynamic where clause. The query has a default where clause where it will always check for SessionId = ? no matter which option is chosen from the students and questions` drop down menu. Then I have a php code where if the user has selected an individual student or an individual question (or in other words has not selected the option All in the student drop down menu or the user has not selected All in the question drop down menu). If the All` option is

Populate HTML Table with database values

纵然是瞬间 提交于 2019-12-25 20:57:14
问题 I have a table that contains city, person, employment_status. I want to populate my html table with this values using PHP, the first td will contain a city the next will contain the total number of people in that city and the third td will contain the total number of people employed. Normally I populate my table using while but this one I don't know how to go about the mysqli query and if while will also work, checked for a solution but can't find, been stuck here for days. <table class=