This question already has answers here:
How to fetch all in assoc array from a prepared statement?
(4 answers)
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(1 answer)
Closed 2 years ago.
I am trying to fetch TaxRate data from a table and I'm trying to select the first array only. However, I keep getting this error
"Fatal error: Uncaught Error: Call to a member function fetch_array()
on boolean in C:\xampp\htdocs\flowerique\shoppingCart.php:77 Stack
trace: #0 {main} thrown in C:\xampp\htdocs\flowerique\shoppingCart.php
on line 77"
Does anyone know the cause of this error and how do I fix it? Thanks!
This is my code :
//Retrieve Current GST Pricing
$qry = "SELECT * FROM gst GROUP BY EffectiveDate DESC";
$stmt = $conn->prepare($qry);
$stmt->execute();
//$stmt->close();
$result = $conn->query($qry);
$row = $result->fetch_array(); // This is line 77
while($row["EffectiveDate"] < date("Y-m-d"))
{
$row = $result->fetch_array();
}
$currentTaxRate = $row["TaxRate"];
This question already has answers here:
Call to undefined method mysqli_result::fetch()
(2 answers)
Closed 1 year ago.
in this code i get the error: Fatal error: Call to undefined method mysqli_stmt::fetch_array()
What is the problem?
$search= "player";
($sql = $db->prepare('select job from jobs where job like ?'));
$sql->bind_param('s', $search);
$sql->execute();
$sql->bind_result($search);
$data = array();
while ($sql->fetch_array(MYSQLI_ASSOC)) {
$data[] = array(
'label' => $row['job']
);
echo json_encode($data);
}
$sql -> close();
$db -> close();
thanks
Using prepared statements there is no fetch_array(). Use mysqli_stmt::fetch() instead or to fetch multiple records use mysqli_result::fetch_all()
Check the manual: mysqli_stmt::fetch() or mysqli_result::fetch_all()
This question already has answers here:
pdo - Call to a member function prepare() on a non-object [duplicate]
(8 answers)
Closed 6 years ago.
I tried to add a section to IMPORT infos from a form into a db table and I get this error:
Fatal error: Call to a member function prepare() on a non-object in /srv/disk7/2173760/www/site.net/admin.php on line 79
and this is the code I tried to use:
<?php
$pdo = new PDO('mysql:host=;dbname=', '', '');
$sql = "SELECT * FROM games LIMIT 10";
foreach ($pdo->query($sql) as $row) {
if(isset($_POST['insert']))
{
$game_title=$_POST['gtitle'];
$yt_id=$_POST['ytlink'];
$name=$_POST['gtitle'];
$source=$_POST['slink'];
$url=$_POST['keysl'];
$steam_id=$_POST['appid'];
$categories=$_POST['inlineRadioOptions'];
$query_ins="INSERT INTO tbl_games(ytlink,gtitle,slink,keysl,appid,keysleft) VALUES(:yt_id,:name,:source,:url,:steam_id,:categories)";
$stmt_query=$dbh->prepare($query_ins);
$games_ins=$stmt_query->execute(array(":yt_id"=>$ytlink,":name"=>$gtitle,":source"=>$slink,":url"=>$keysl,":steam_id"=>$appid,":categories"=>$keysleft));
if(!$games_ins)
{
$error=$stmt_query->errorInfo();
echo $error['2'];
}
}
?>
this is line 79:
$stmt_query=$dbh->prepare($query_ins);
I replaced with this and still don't working..
<?php
$pdo = new PDO('mysql:host=;dbname=', '', '');
$sql = "SELECT * FROM games LIMIT 10";
foreach ($pdo->query($sql) as $row) {
$query = "INSERT INTO tbl_games(yt_id,name,url,source,keysleft,steam_id)".
"SELECT ytlink,gtitle,slink,keysl,appid FROM games LIMIT 10"
?>
You have to instantiate $dbh before use it, like you've done with $pdo.
Why don't you use the object $pdo from the second line instead?
This question already has answers here:
Fatal error: Call to undefined function mysqli_result()
(2 answers)
Closed 6 years ago.
I have problem with mysqli_result() -> (ex mysql_result)
My code:
$per_page = 6;
$pages_query = mysqli_query($conn, 'SELECT COUNT(id) FROM users');
$pages = ceil(mysqli_result($pages_query, 0) / $per_page);
browser error:
Fatal error: Call to undefined function mysqli_result() in /Applications/MAMP/htdocs/bootstrap/pagination.php on line 11
As opposed to mysql_result(), there's no mysqli_result() function available in MySQLi.
Use mysqli_fetch_array() function to get the total number of rows. Your code should be like this:
$per_page = 6;
$pages_query = mysqli_query($conn, 'SELECT COUNT(id) FROM users');
$row = mysqli_fetch_array($pages_query);
$pages = ceil($row[0] / $per_page);
This question already has answers here:
Call to undefined method mysqli_result::fetch()
(2 answers)
Closed 1 year ago.
in this code i get the error: Fatal error: Call to undefined method mysqli_stmt::fetch_array()
What is the problem?
$search= "player";
($sql = $db->prepare('select job from jobs where job like ?'));
$sql->bind_param('s', $search);
$sql->execute();
$sql->bind_result($search);
$data = array();
while ($sql->fetch_array(MYSQLI_ASSOC)) {
$data[] = array(
'label' => $row['job']
);
echo json_encode($data);
}
$sql -> close();
$db -> close();
thanks
Using prepared statements there is no fetch_array(). Use mysqli_stmt::fetch() instead or to fetch multiple records use mysqli_result::fetch_all()
Check the manual: mysqli_stmt::fetch() or mysqli_result::fetch_all()