mysqli

MySQL procedure returns empty result to PHP

僤鯓⒐⒋嵵緔 提交于 2021-02-20 19:57:48
问题 I have an issue where I wrote a stored procedure that inserts data into a bunch of tables and then finally returns and id by selecting it. when I execute the stored procedure in PHPMyAdmin, the data is inserted and the ID returned. When executing the procedure from PHP using MySQLi, the data is inserted into the tables however when I check the results to retrieve the new id, the result seems to be blank. Any help here would be appreciated. I am not sure if the procedure returns empty results

MySQLi get_result() undefined when mysqlnd is installed

*爱你&永不变心* 提交于 2021-02-18 11:11:22
问题 I am writing a simple test script to get my head around MySQLi prepared statements. This script will become the basis for a function that needs to be slightly dynamic in its handling of results. I need the fetch method to return as an array similar to how mysql_fetch_array() behaves. I am aware some of these methods require mysqlnd. I have checked phpinfo. Mysqlnd is installed and present. See screenshot. Please note, PDO is available on my server, but I need to get this script working with

MySQLi get_result() undefined when mysqlnd is installed

三世轮回 提交于 2021-02-18 11:05:31
问题 I am writing a simple test script to get my head around MySQLi prepared statements. This script will become the basis for a function that needs to be slightly dynamic in its handling of results. I need the fetch method to return as an array similar to how mysql_fetch_array() behaves. I am aware some of these methods require mysqlnd. I have checked phpinfo. Mysqlnd is installed and present. See screenshot. Please note, PDO is available on my server, but I need to get this script working with

mysqli_multi_query - Commands out of sync; you can't run this command now

允我心安 提交于 2021-02-18 10:56:47
问题 I have several query strings which I want to execute at once using "mysqli_multi_query". This works. When I insert a query again to check each item in joined tables using "mysqli_query" it doesn't return any result nor any error from PHP. When I run the query string manually in phpmyadmin, everything works fine as it should. Here's my code: <?php $connect = mysqli_connect('localhost','root','','database'); $strquery = ""; $strquery .= "1st Query"; $strquyer .= "2nd Query"; if($multi = mysqli

No Database selected error in PHP with MySQLi [duplicate]

為{幸葍}努か 提交于 2021-02-17 07:18:29
问题 This question already has answers here : How to make mysqli connect function? (2 answers) Closed 4 years ago . I have to select data from MySQL Database. I have been looking for the answer, but still haven't found any. I am learning from W3School My MySQL doesn't have any username or password, so my code looks like this: <?php $servername = "localhost"; $dbName = "db_Test"; //Create Connection $conn = mysqli_connect($servername, $dbName); //Check Connection if(!$conn){ die("Connection Failed.

While Loop only returns one row from 9000+ records

烂漫一生 提交于 2021-02-17 07:06:47
问题 I had a script for this that worked great in PHP 5.3. New host only supports 5.5 so I've done some modifying. So far, I can only get one row to be returned. I've been agonising for hours and I just can't see why. Is this possibly because I'm not using array_push() after the while loop? In my original script I had it but found out with this one I got a 500 Internal Server Error with it which disappeared if I took it out. <?php $mysqli = mysqli_connect("localhost", "user", "password", "database

Mysqli -> num_rows always returns 1

烈酒焚心 提交于 2021-02-17 05:20:12
问题 This seems to always return 1 for $item_result->num_rows; even though there are 0 rows in the DB. However, if an item exists it updates the row correctly. I'm sure something is wrong with my syntax but I'm having a hard time wrapping my head around this mysqli. $item_query = "SELECT COUNT(*) FROM `rel` WHERE `cart_id` = '".$cartId."' && `id_item` = '".$item_id."'"; $item_result = $mysqli->query($item_query) or die($mysqli->error.__LINE__); if($item_result->num_rows==1) { $item_query2 =

bind_result() - Number of variables doesn't match number of fields

不想你离开。 提交于 2021-02-17 03:35:31
问题 Code: // get value of id that sent from address bar $id=filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT); if ($id === false) { //filter failed die('id not a number'); } if ($id === null) { //variable was not set die('id not set'); } //white list table $safe_tbl_name = ''; switch($tbl_name){ case 'Table1': $safe_tbl_name = 'MyTable1'; break; case 'Table2': $safe_tbl_name = 'MyTable2'; break; default: $safe_tbl_name = 'forum_questions'; }; $sql="SELECT * FROM `$safe_tbl_name` WHERE id=?"; if

Undefined variable: mysqli & call to a member function query() on null

为君一笑 提交于 2021-02-17 03:16:46
问题 I'm kinda new to mysqli and I'm trying to display data on a table. Here's the code: <tbody> <?php $query = $mysqli->query("SELECT username,password,FName,LName,userAddress FROM tbl_users"); $no = 1; while($row = $query->fetch_assoc()){ ?> <tr> <td><?php echo $no++ ?></td> <td><?php echo $row['username'] ?></td> <td><?php echo $row['password'] ?></td> <td><?php echo $row['FName'] .' '. $row['LName'] ?></td> <td><?php echo $row['userAddress'] ?></td> <td> <a href="update.php?id=<?php echo $row[

Undefined variable: mysqli & call to a member function query() on null

倾然丶 夕夏残阳落幕 提交于 2021-02-17 03:16:20
问题 I'm kinda new to mysqli and I'm trying to display data on a table. Here's the code: <tbody> <?php $query = $mysqli->query("SELECT username,password,FName,LName,userAddress FROM tbl_users"); $no = 1; while($row = $query->fetch_assoc()){ ?> <tr> <td><?php echo $no++ ?></td> <td><?php echo $row['username'] ?></td> <td><?php echo $row['password'] ?></td> <td><?php echo $row['FName'] .' '. $row['LName'] ?></td> <td><?php echo $row['userAddress'] ?></td> <td> <a href="update.php?id=<?php echo $row[