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"
Related
This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Closed 6 years ago.
what is error in this code output is
Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\xamp\htdocs\LMS\LMS\all_books.php on line 60
<?php
$sql1=mysql_query("SELECT COUNT(*) FROM book_list where book_id=$id AND status=0 AND item_type=0 AND condition='new'");
$count1 = mysql_result($sql1, 0, 0);
echo $count1;
?>
The function mysql_result() expects a resource (a mysql result-set) as its first parameter but has instead been supplied with a boolean (true/false) value.
This is likely because your SQL query is malformed (condition is a reserved keyword); You ought to enclose your table and column names in backticks, for example:
SELECT COUNT(*) FROM `book_list` WHERE `book_id`=$id AND `status`=0 AND `item_type`=0 AND `condition`='new'
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_fetch_assoc(): supplied argument is not a valid MySQL result … [duplicate]
(3 answers)
Closed 8 years ago.
I have a php code where I just query to insert rows into table via POST method every thing happens fine with WARNING ,I couldn't figure out why is that a warning message
WARNING MESSAGE IS:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/a266/public_html/poster.php on line 9
CODE IS:
include "db.php";
$sql=mysql_query("INSERT INTO tb1 (col1,col2) VALUES ('$_val1', '$_val2')");
while($row=mysql_fetch_assoc($sql))
$output[]=$row;
$result="inserted";
NOTE :Value is perfectly inserted into table and returns "inserted" message But why is that warning..?
INSERT just returns true or false.There is no result to fetch with INSERT query.
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:
Closed 10 years ago.
Possible Duplicate:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
$query = "SELECT UniqueID FROM configuration";
$result = mysql_query($query)or die(mysql_error());;
while($row = mysql_fetch_assoc($result)) { }
throwing exception as
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\ehp\hello.php on line 10
That's slightly confusing, since this sort of thing is usually caused by an SQL error, however the line ..or die(mysql_error()); should have picked that up. Check the contents of your loop that you're not overwriting the $result variable.