mysqli

Pagination display error using mysqli

浪子不回头ぞ 提交于 2020-01-25 10:52:06
问题 I want to display 10 records per page This code works fine when i set the line $per_page = 1 by using this 1 record per page is displayed and the option to move to next page also appears when i update this line to $per_page = 10; all the records are displayed but Move to next page options disappears There are two files view_data.php in which the complete logic is written and pagination.php in which pagination layout code is written **// view_data.php** <?php include_once('pagination.php');

Unable to get simple PHP form to add/update to MySQL table

拈花ヽ惹草 提交于 2020-01-25 07:56:06
问题 I have a MySQL table with three columns; user, product, address. I am trying to get my form to either add to the table a NEW ROW OF DATA OR UPDATE a pre-existing row. My conditions for update are IF both user and product already exist, just change address. BUT IF neither exist (user and product), or just user, then append new user, product, and address info. The form uses customer id, a dropdown box for the product, and a text box for the new address, however my SQL command for update seems

How to connect to remote mysql database using php (hosted on dotCloud)

試著忘記壹切 提交于 2020-01-24 10:24:02
问题 I am unable to connect to my database residing on dotCloud. I tried: $mysqli = new mysqli($db_host, $db_user, $db_password, $db_name); and $mysqli = mysqli_connect($db_host, $db_user, $db_password, $db_name); and $mysqli = new mysqli($remote_server, $db_user, $db_password, $db_name); and $mysqli = mysqli_connect($remote_server, $db_user, $db_password, $db_name); but it fails to connect, and I get "Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data."

How to connect to remote mysql database using php (hosted on dotCloud)

牧云@^-^@ 提交于 2020-01-24 10:23:00
问题 I am unable to connect to my database residing on dotCloud. I tried: $mysqli = new mysqli($db_host, $db_user, $db_password, $db_name); and $mysqli = mysqli_connect($db_host, $db_user, $db_password, $db_name); and $mysqli = new mysqli($remote_server, $db_user, $db_password, $db_name); and $mysqli = mysqli_connect($remote_server, $db_user, $db_password, $db_name); but it fails to connect, and I get "Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data."

Get and insert Data into MySQL database using PHP with xampp on localhost

冷暖自知 提交于 2020-01-23 22:33:51
问题 I have managed to connect to database and I manage to insert using following code. <?php $username = 'root'; $password = ''; $db = 'demo'; $conn = new mysqli ('localhost',$username, $password, $db) or die("unable to connect"); $sql="insert into persons (first_name,last_name,email_address) values ('sara','smith','email@email.com')"; $query=mysqli_query($conn,$sql); if($query) echo 'data inserted'; ?> But the problem is that when I try to enter data using HTML form, it didn't work for me. I

PHP PDO: Unable to connect, Invalid catalog name

笑着哭i 提交于 2020-01-23 05:16:52
问题 I am trying to set up a new site on my hosting (Host route if it matters) but i keep getting this error when i try using PDO (first PDO site im trying): Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected' in /home/kennyi81/public_html/gamersite/login.php:36 Stack trace: #0 /home/kennyi81/public_html/gamersite/login.php(36): PDOStatement->execute() #1 {main} thrown in /home/kennyi81/public_html/gamersite/login.php on

How to store a single column of a single row out of a MySQLi prepared statement in a PHP variable?

橙三吉。 提交于 2020-01-22 03:02:04
问题 I'm very new to PHP and MySQL and I'm looking for a solution to store a single value of a database row in a variable using a prepared statement. Right now this is the prepared statement and execution: $emailsql = $conn->prepare("SELECT email FROM User WHERE email = ? limit 1;"); $emailsql->bind_param('s', $email); $emailsql->execute(); I tried get_result() , fetch() , fetch_object() and I'm out of ideas and google search results. 回答1: You need to add to your code the binding of the result to

Insert multiple values from API into mysql database

纵然是瞬间 提交于 2020-01-22 02:31:29
问题 I am connected to an API that keeps track of customer orders. Some orders have one product but some orders have multiple products in one order. When I try and INSERT into my database I only get the first product. I would like to have all the products inserted in the cases where their are more than one. The API's XML to the productName is ->orderItems->orderItem->productName and I am trying to loop through all of them but I still only get the first product. foreach ($customer_orders as

Is “key” a reserved word in MySqli? I'm getting an error

北城余情 提交于 2020-01-22 02:31:08
问题 I'm just getting into MySql/MySqli really, and I'm using prepared statements. The whole of my script is working fine except this single line: if ($stmt = $con->prepare("SELECT bandHash, userHash, userPassHash, type FROM account_active WHERE key=?")) { I found out that's the line by manually tracking it down, then running the mysqli_error($resource) function, and got this result You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right

Is is bad practice to use array_walk with mysqli_real_escape_string?

放肆的年华 提交于 2020-01-22 02:13:08
问题 So I have a function called "escape" that looks like this: function escape($string){ $escaped_string = mysqli_real_escape_string($this->conn, $string); return $escaped_string; } I before running a query I send a variable (originated from user input obviously) here so its escaped for security reasons. Now I know its possible to use array_walk to apply an array of values to this function, but I just want to know if there is any reason why I shouldn't? I know it sounds like a daft question but