Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

Reply

Join Date: Nov 2007
Posts: 3,746
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

 
0
  #11
Dec 7th, 2007
  1. $user_id=$_POST['UserID'];
  2. $password=$_POST['Password'];
  3. $query="select * from Customer where
  4. UserID = '$user_id' and Password = '$password'";
  5. echo $query;
  6. $result=mysql_query($query) or die(mysql_error());

Check what $query prints. Execute the same in phpmyadmin.

oh, and please, next time you post your code, put it in [code] tags.
Last edited by nav33n; Dec 7th, 2007 at 8:54 am.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 1
Reputation: luqyan is an unknown quantity at this point 
Solved Threads: 0
luqyan luqyan is offline Offline
Newbie Poster

Re: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

 
0
  #12
May 13th, 2009
y need some help pls
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\xxxxxxxxx\index.php on line 7
No Template Selected


  1. require("dbconfig.php");
  2. $con =mysql_connect ($db_host,$db_user,$db_pass) or die("Error connecting");
  3. mysql_select_db($db_name,$con);
  4. $tem="select dir from template where active='1'";
  5. $temr=mysql_query($tem,$con);
  6. $temn=mysql_num_rows($temr); line 7
  7. if($temn==0)
Last edited by peter_budo; May 15th, 2009 at 7:14 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

 
0
  #13
May 13th, 2009
Originally Posted by luqyan View Post
y need some help pls
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\xxxxxxxxx\index.php on line 7
No Template Selected


require("dbconfig.php");
$con =mysql_connect ($db_host,$db_user,$db_pass) or die("Error connecting");
mysql_select_db($db_name,$con);
$tem="select dir from template where active='1'";
$temr=mysql_query($tem,$con);
$temn=mysql_num_rows($temr); line 7
if($temn==0)
Excuse me. Did you not see the GIANT GLARING STICKIED POST that said "FAQ: Supplied argument not valid resource"? How about you go back and take a look at that.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 1
Reputation: chirag87 is an unknown quantity at this point 
Solved Threads: 0
chirag87 chirag87 is offline Offline
Newbie Poster
 
-2
  #14
32 Days Ago
$rsEmpresa = mysql_query($SQLEmpresa,$conexion) or die(mysql_error());
//add the text shown in BOLD, this will atleast display what error you are having
Originally Posted by janzaldo View Post
when im test in my local machine i dont have any error but when im trying to test in web i have this error, the same DB, the same tables, the same data in both structures any idea????

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtual/site244/fst/var/www/html/categoria.php on line 107


  1. <?php
  2. require('conexion2.php');
  3. $SQLEmpresa= "SELECT empresa.cve_Empresa, Nombre, Direccion, pagina, telefono
  4. FROM empresa, empresa_Categoria
  5. WHERE ".$_GET['cve_Categoria']." = empresa_Categoria.cve_Categoria
  6. AND empresa_Categoria.cve_Empresa = empresa.cve_Empresa";
  7. $rsEmpresa = mysql_query($SQLEmpresa,$conexion);
  8. $reg = array();
  9. -->line 107 while ($reg = mysql_fetch_array($rsEmpresa))
  10. {
  11. $nombre = $reg["Nombre"];
  12. $direccion = $reg["Direccion"];
  13. $telefono = $reg["telefono"];
  14. $pagina = $reg["pagina"];
  15. $cve_Empresa = $reg["cve_Empresa"];
  16. ?>
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 525
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 61
network18 network18 is offline Offline
Posting Pro
 
-1
  #15
32 Days Ago
your query is failing for sure, echo the query and post it here.
or else execute the query directly inside the mysql and post ,if any error you got there
"The discipline of writing something down is the first step towards making it happen."

follow me on twitter
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 7
Reputation: srinivasjinde is an unknown quantity at this point 
Solved Threads: 0
srinivasjinde srinivasjinde is offline Offline
Newbie Poster
 
-1
  #16
21 Days Ago
please help me...even i m getting this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\admin_loggedin_search_admin.php on line 35

[code=php]
<?php
$con = mysql_connect("localhost","root","");
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("polling",$con);
$result = mysql_query("SELECT * FROM administrator WHERE $_POST[searchby] like '%$_POST[query]%'");
$found=0;
[LINE 35]while($sri=mysql_fetch_array($result))
{
if($sri['name']!="")
{
$found++;
echo "&nbsp;&nbsp;&nbsp;&nbsp; ".$sri['name']."->".$sri['username']."<br />";
}
}
if($found!=0)
{echo "Found ".$found." results!";}
mysql_close($con)
?>
[code/]
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 147
Reputation: venkat0904 is an unknown quantity at this point 
Solved Threads: 15
venkat0904's Avatar
venkat0904 venkat0904 is offline Offline
Junior Poster
 
0
  #17
21 Days Ago
your query doesnt seems right to me... try this
  1. $query = "SELECT * FROM administrator WHERE".$_POST[searchby]."like '%".$_POST[query]."%'";
  2. $result = mysql_query($query);

always try to create n store ur query in a separate variable.. helps in debugging.
Hope this helps... cheers!!

Originally Posted by srinivasjinde View Post
please help me...even i m getting this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\admin_loggedin_search_admin.php on line 35

  1. <?php
  2. $con = mysql_connect("localhost","root","");
  3. if(!$con)
  4. {
  5. die('Could not connect: ' . mysql_error());
  6. }
  7. mysql_select_db("polling",$con);
  8. $result = mysql_query("SELECT * FROM administrator WHERE $_POST[searchby] like '%$_POST[query]%'");
  9. $found=0;
  10. [LINE 35]while($sri=mysql_fetch_array($result))
  11. {
  12. if($sri['name']!="")
  13. {
  14. $found++;
  15. echo "&nbsp;&nbsp;&nbsp;&nbsp; ".$sri['name']."->".$sri['username']."<br />";
  16. }
  17. }
  18. if($found!=0)
  19. {echo "Found ".$found." results!";}
  20. mysql_close($con)
  21. ?>
Last edited by venkat0904; 21 Days Ago at 1:48 am.
Gimme reputation points if u find my post helpful.
use [code] tags wherever applicable
dont start a new thread unless u cant find the topic already on forum.
mark a thread "solved" as soon as u get a solution
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 7
Reputation: srinivasjinde is an unknown quantity at this point 
Solved Threads: 0
srinivasjinde srinivasjinde is offline Offline
Newbie Poster
 
0
  #18
21 Days Ago
@venkat
doesnt help...now i am getting an parse error in the line select * .......

are you sure of the syntax in the sql query??
one more thing....$_post[query] ... returns the string entered in a search box named query.....
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 147
Reputation: venkat0904 is an unknown quantity at this point 
Solved Threads: 15
venkat0904's Avatar
venkat0904 venkat0904 is offline Offline
Junior Poster
 
0
  #19
21 Days Ago
ohhh m so sorry... didn't include the spaces.. my bad.
just add a space after "where" clause and before "like".
should be--
  1. $query = "SELECT * FROM administrator WHERE ".$_POST[searchby]." like '%".$_POST[query]."%'";

n do make sure that ur "searchby" parameter feeds the column name exactly as in ur table..(upper n lower case are considered different)

try this n lemme know..
cheers!!

Originally Posted by srinivasjinde View Post
@venkat
doesnt help...now i am getting an parse error in the line select * .......

are you sure of the syntax in the sql query??
one more thing....$_post[query] ... returns the string entered in a search box named query.....
Last edited by venkat0904; 21 Days Ago at 3:29 am.
Gimme reputation points if u find my post helpful.
use [code] tags wherever applicable
dont start a new thread unless u cant find the topic already on forum.
mark a thread "solved" as soon as u get a solution
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 7
Reputation: srinivasjinde is an unknown quantity at this point 
Solved Threads: 0
srinivasjinde srinivasjinde is offline Offline
Newbie Poster
 
0
  #20
20 Days Ago
The prob. is still there....anyway the search functionality is working well....the only thing is that the warning msg doesnt look good....and when i do the first search by entering a query....i get the search results and the error msg disappears...
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC