mysqli

Warning: mysqli_connect(): Unknown MySQL server host

扶醉桌前 提交于 2020-01-14 05:28:11
问题 I have some trouble connecting to a mysql server. I can connect using the linux terminal, so I know that my host, port, user, and password works. I cannot, however, connect using PHP. PHP Version: 5.2.17 Server version: 5.5.27-log MySQL Community Server (GPL) Here is a test code example: <?php $link = mysqli_connect('host.com:5306', 'user', 'pass', 'db'); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } if (!mysqli_query(

PHP searching multiple rows in database

故事扮演 提交于 2020-01-14 03:14:29
问题 I am wanting to search more than column from one database with PHP and MySQL. Currently I have this working. This is my form: <form action="products.php" method="POST"> Search: <input type="text" name="search" /> <input type="submit" value="submit"/> </form> and here is my current working query: $query = "SELECT * FROM `GraphicsCards` WHERE `Brand` LIKE '%". $search . "%'"; $run = mysqli_query ($connection, $query); As you can see my query is searching my database to see if the user search

Search mysqli for multiple values in one column, return matching another, sort by count of occurrences?

时光怂恿深爱的人放手 提交于 2020-01-14 02:59:10
问题 Before I start, here is the sample format of the database: id date title content -------------------------------------------------------------- 1 YYYY-MM-DD some text here lots of stuff to search here 2 YYYY-MM-DD some text here lots of stuff to search here 3 YYYY-MM-DD some text here lots of stuff to search here I currently have something set up to get the id of a row, then assign the date, title, and content to PHP variables to display in different places on a page (it's a blog, these are

PHP, mysqli, and table locks?

那年仲夏 提交于 2020-01-13 20:41:17
问题 I have a database table where I need to pull a row, test user input for a match, then update the row to identify the user that made the match. Should a race condition occur, I need to ensure that the first user's update is not overwritten by another user. To accomplish this I intend to: 1. Read row 2. Lock table 3. Read row again and compare to original row 4. If rows match update, otherwise do nothing (another user has already updated the row) Based on information I found on Google, I

How to show SQL error in PHP custom mysqli function?

孤人 提交于 2020-01-13 14:57:30
问题 I have found a PHP custom function for mysqli query functions, but my problem is, how can I show an error of the mysqli function? Here is the sample php mysqli function: function connect() { $con = mysqli_connect(DB_HOST, DB_USER, DB_PASS); $db = mysqli_select_db($con, DB_NAME); return $con; } Query Function: function query($sql) { return mysqli_query(connect(),$sql); } Fetch Assoc Function: function fetchAssoc($sql) { return mysqli_fetch_assoc($sql); } And here is how it was called or used:

How to show SQL error in PHP custom mysqli function?

我的未来我决定 提交于 2020-01-13 14:57:10
问题 I have found a PHP custom function for mysqli query functions, but my problem is, how can I show an error of the mysqli function? Here is the sample php mysqli function: function connect() { $con = mysqli_connect(DB_HOST, DB_USER, DB_PASS); $db = mysqli_select_db($con, DB_NAME); return $con; } Query Function: function query($sql) { return mysqli_query(connect(),$sql); } Fetch Assoc Function: function fetchAssoc($sql) { return mysqli_fetch_assoc($sql); } And here is how it was called or used:

How can I pre-select a dropdown option using previously submitted data from database, MySQLI

女生的网名这么多〃 提交于 2020-01-13 13:08:49
问题 I have two tables: orders and companies . Note that both tables has a company_id row. Orders Table : order_id | order_name | company_id | ..... Companies Table : company_id | company_name | ..... I have a page with a form that INSERTS data for an order into the orders table in my database. Part of the order is selecting a company from the companies table to go with it, so I use a dropdown for this. I also have another page with a form that UPDATES that data (an edit page). When I click on the

How can I pre-select a dropdown option using previously submitted data from database, MySQLI

99封情书 提交于 2020-01-13 13:08:11
问题 I have two tables: orders and companies . Note that both tables has a company_id row. Orders Table : order_id | order_name | company_id | ..... Companies Table : company_id | company_name | ..... I have a page with a form that INSERTS data for an order into the orders table in my database. Part of the order is selecting a company from the companies table to go with it, so I use a dropdown for this. I also have another page with a form that UPDATES that data (an edit page). When I click on the

Error “mysqli::real_connect(): (HY000/2002): Only … permitted.”

好久不见. 提交于 2020-01-13 09:34:17
问题 The ERROR: mysqli_real_connect(): (HY000/2002): Only one usage of each socket address (protocol/network address/port) is normally permitted. However, it appears I have enough ports . DETAILS: I have a MySQL server that has been running for several months without issue. I am running Windows 10, PHP 7.0 and MySQL 5.7 . This is a busy server with a high volume of transactions per hour. For about a week now, I have been getting an excessive volume of: mysqli_real_connect(): (HY000/2002): Only one

query mysql database from inside a class

…衆ロ難τιáo~ 提交于 2020-01-13 04:28:47
问题 I'm trying to run a query to a MySQL database from within a class and it's not working for some reason. I have the class in a separate file which I'm linking to with the require_once() function. here's what the main .php file looks like: <?php require_once("connect.php"); require_once("theClass.php"); $a = new theClass; $a->runQuery(); } connect.php: <?php //connect to mySQL database $mysqli = new mysqli("host", "user", "password", "db"); if ($mysqli->connect_errno) { echo "<br><h1>Failed to