mysqli

Prepared statements while fetching prepared statement

送分小仙女□ 提交于 2020-01-06 07:55:31
问题 I want to make a loop with one INSERT query for each fetched row from a previous query with prepared statements. In a more visual way: MAKE QUERY While Fetching - Make new query I can't close my statement since I need it to keep working... The problem is that when we use prepared statements, we have to fetch all data before doing a new prepare(). So, how could I do this? Maybe without statements, but it's not a nice solution. 回答1: You are going to kill your DB (and if you have a DBA your DBA

Error - Trying to get property 'num_rows' of non-object [duplicate]

这一生的挚爱 提交于 2020-01-06 06:24:51
问题 This question already has answers here : Reference - What does this error mean in PHP? (35 answers) 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) Closed last year . I want to ask why am I getting this error: Trying to get property 'num_rows' of non-object with the following code: $sql = "SELECT * FROM $table_name ORDER BY Author"; $result = $mysqli->query($sql); if ($result->num_rows > 0) {... I

MYSQL - Get all children from the parents

家住魔仙堡 提交于 2020-01-06 05:50:10
问题 I have stuck in getting all children's query where parent id greater than the customer id table test id name parent 1 test1 0 2 test2 1 3 test3 1 4 test4 2 5 test5 2 6 test6 10 7 test7 10 8 test8 6 9 test9 6 10 test10 5 11 test10 7 Currently I am using this recursive query but it shows children till the 10 parent but not able to give children of 6 and 7 and further SELECT id , parent FROM (SELECT id , parent from (SELECT * FROM test order by parent , id) testdata_sorted, (SELECT @pv := '1')

fetch_array with prepared statement? PHP MYSQL?

走远了吗. 提交于 2020-01-06 05:35:09
问题 For some reason I cannot get this to work for the life of me, I am new to prepared statements! $q = $dbc -> prepare ("SELECT * FROM accounts WHERE email = ? && logcount = ''"); $q -> bind_param ('s', ($_SERVER['QUERY_STRING'])); $row = $q -> fetch_array(MYSQLI_ASSOC); $q -> execute(); $q -> store_result(); if ($q -> num_rows == 1) { $q = $dbc -> prepare("UPDATE accounts SET logcount = '0' WHERE email = ?"); $q -> bind_param('s', ($_SERVER['QUERY_STRING'])); $q -> execute(); echo '

Page is redirecting to my php script from form

六月ゝ 毕业季﹏ 提交于 2020-01-06 05:05:31
问题 I am trying to make a login system with php but i cant figure out why my form is just redirecting me to the script file when i click on my login button. it works fine on my sign up form. everything seems to work exept its redirecting me to the script file. My php file that contains my form: https://codepen.io/hubbe-andersson/pen/yGOPoM EDIT: I have put my phpscript into my header.php instead and now im getting ERR_TOO_MANY_REDIRECTS in chrome what is caussing this? <?php if(isset($_POST[

mysqli bind variables

末鹿安然 提交于 2020-01-06 04:51:07
问题 I have this partial code: if ($getRecords = $con->prepare("SELECT * FROM AUCTIONS WHERE ARTICLE_NO = ?")) { $getHtml = $con->prepare("SELECT ARTICLE_DESC FROM AUCTIONS WHERE ARTICLE_NO = ?"); $getHtml->bind_param("i", $pk); $getHtml->execute(); $getHtml->bind_result($ARTICLE_DESC); $getRecords->bind_param("i", $pk); $getRecords->execute(); $getRecords->bind_result($ARTICLE_NO, $ARTICLE_NAME, $SUBTITLE, $CURRENT_BID, $START_PRICE, $BID_COUNT, $QUANT_TOTAL, $QUANT_SOLD, $ACCESSSTARTS,

connect external db with codeIgniter

我怕爱的太早我们不能终老 提交于 2020-01-06 02:49:08
问题 i am new in code igniter, i tried to connect with local db then successfully connected,but while connecting with external db it resulting an error A PHP Error was encountered Severity: Warning Message: mysqli::real_connect(): (HY000/2003): Can't connect to MySQL server on 'xxxxx.gridserver.com' (110) Filename: mysqli/mysqli_driver.php Line Number: 202 Backtrace: File: /var/www/html/restapi/application/libraries/REST_Controller.php Line: 375 Function: __construct File: /var/www/html/restapi

PHPs mysqli prepare - generate dynamically

一笑奈何 提交于 2020-01-06 02:44:20
问题 My code to generate the SQL statement works fine - however I run into a hiccup when generating the string for $stmt->bind_param. Code is as follows: $stmt = $mysqli->stmt_init(); if ($stmt->prepare ($sql)) { $bind_types = '"'; $bind_values = ''; if ($action == 'insert' || $action == 'update') { reset ($array); foreach ($array as $key => $value) { if (is_string ($value)) { $type = 's'; } else if (is_int ($value)) { $type = 'i'; } else if (is_float ($value)) { $type = 'd'; } else { die ('Cannot

Matching Different Value within One Row

て烟熏妆下的殇ゞ 提交于 2020-01-06 02:14:35
问题 I want to perform a query whereby I want to check whether on the columns A has either certain values. A could have only X , X and Y or a combination of X Y and Z. To give a better understanding. I am checking a book's author within a table itself. The table has the BOOK_ID , BOOK_TITLE , AUTHOR_NAME, AUTHOR_ORDER. So a book might have 1,2 or 3 authors, listed in order written inside the AUTHOR_ORDER row. I am trying very hard to reach an output where if a book has 3 authors, it will display

msqli does not INSERT

ぃ、小莉子 提交于 2020-01-06 01:10:08
问题 im trying to insert data from a form (via POST) into a MySQL database, it does not show any errors, but it does not show up when I check it in phpMyAdmin. <?php $amount = $_POST["amount"]; $unit = $_POST["unit"]; $date = date('Y-m-d H:i:s'); $host = "localhost"; $user = "root"; $pass = ""; $db = "finance"; $table = "silver"; $mysqli = new mysqli($host, $user, $pass, 'finance'); if(!$mysqli) { echo "<div class=\"error\">"; echo "No connection can be established"; echo "</div>"; die(); } if (