This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Can I mix MySQL APIs in PHP?
(4 answers)
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(2 answers)
Closed 5 years ago.
I need help with this:
$query="SELECT productos.id_producto, productos.nombre, productos.precio,
ci.quantity, ci.quantity * productos.precio AS subtotal
FROM productos p
LEFT JOIN cart_items ci
ON ci.id_producto = productos.id_producto";
$com = mysqli_query($cnx, $query);
$row = mysqli_fetch_assoc($com);
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given in "XXXXX" on line 34
In this case is line = 6.
Sorry if this is "simple php" error.
I'm learning PHP.
You have an error on your SQL statement. You've given an alias to your table productos as p but your calling the fields using the table name itself. Try to remove the alias name and you're good to go.
$query="SELECT productos.id_producto, productos.nombre, productos.precio,
ci.quantity, (ci.quantity * productos.precio) AS subtotal
FROM productos
LEFT JOIN cart_items ci
ON ci.id_producto = productos.id_producto";
Related
This question already has answers here:
Are you allowed to use numbers as table names in MySQL?
(5 answers)
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(1 answer)
Reference - What does this error mean in PHP?
(38 answers)
Closed 5 years ago.
<?php include('header.php');
include('config.php');
if (isset($_POST['submit']))
{
$link1=mysqli_real_escape_string($cone,$_POST['link1']);
$link2=mysqli_real_escape_string($cone,$_POST['link2']);
$link3=mysqli_real_escape_string($cone,$_POST['link3']);
$link4=mysqli_real_escape_string($cone,$_POST['link4']);
$link5=mysqli_real_escape_string($cone,$_POST['link5']);
$sql = "update path set 1='hello' where id=1";
if (mysqli_query($cone,$sql))
{
header("location:section_6.php?done");
}
}
?>
What am i doing wrong here ? The Cone variable is defined in config.php but i can't get the update working and there's no error.
This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 8 years ago.
When I restart my page I received following mistake:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in
on this string:
while($row=mysql_fetch_array($emp_query)){ $id=$row['history_id'];"
What I did wrong in this code? Without following words in my MySQL query:
"WHERE user Like"
my code is work.
My code
<?php
$emp_query=mysql_query("SELECT * FROM `history` WHERE user LIKE $login_session");
while($row=mysql_fetch_array($emp_query)){ $id=$row['history_id'];
?>
<td>........</td>
<?php }?>
There is a problem with your SELECT query that's why it through error on mysql_fetch_array , try this way & use % if you want to match like '$login_session%' or '%$login_session' or '%$login_session%'
$emp_query=mysql_query("SELECT * FROM `history` WHERE user LIKE '".$login_session."'");
NB: move on to mysqli or PDO as adeneo advised
This question already has answers here:
MySQL & PHP Parameter 1 as Resource
(3 answers)
Closed 9 years ago.
I'm trying to do this:
<?php
$query ="SELECT * FROM servers, bans WHERE servers.ServerID = bans.ServerID ORDER BY BanID DESC";
$result = mysql_query($query);
while($row=mysql_fetch_assoc($result)){
?>
but I get this error:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Access\repository\HT2\WH\www.voltzgaming.com\public_html\GBans\index.php on line 139
Your mysql_query($query) is returning a false because you have a syntax error in the SQL.
Use mysql_error() after the query is run to see what the problem is.
This question already has answers here:
Mysql_fetch_array supplied argument is not a valid MYSQL result
(4 answers)
Closed 9 years ago.
$query_user2 = mysql_query("SELECT TOP 1 * FROM $var WHERE id = (rand() * (SELECT MAX(id) FROM $var))");
$estrai2 = mysql_fetch_array($query_user2);
Problem: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
Why? :/
TOP 1 is a sql server ( not MySQL ) command to select the first row, remove that and add LIMIT 1 to the end of the query.
you might want to alter your question. The problem is your query, not the "supplied argument is not a valid mysql result"
This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 9 years ago.
I have small errors when I add date to my database.
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\chemmad\register.php on line 17.
But it works fine in my web server, but it is not working from local host.
mysql_num_rows is deprecated and you should not use it.
The correct way to count the number of rows in php is:
$db = new PDO( ... db connection details ...);
$q = $db->query('SELECT a, b, c FROM tbl WHERE oele = 2 GROUP BY boele');
$rows = $q->num_rows;
print $rows;