1,105,578 Community Members

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

Member Avatar
janzaldo
Newbie Poster
3 posts since Jul 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

<?php
    require('conexion2.php');
    $SQLEmpresa= "SELECT empresa.cve_Empresa, Nombre, Direccion, pagina, telefono 
	             FROM empresa, empresa_Categoria  
		WHERE ".$_GET['cve_Categoria']." = empresa_Categoria.cve_Categoria 
		 AND empresa_Categoria.cve_Empresa = empresa.cve_Empresa";
    $rsEmpresa = mysql_query($SQLEmpresa,$conexion);
	$reg = array();
-->line 107	while ($reg = mysql_fetch_array($rsEmpresa))
	   {		
			$nombre =  $reg["Nombre"]; 
			$direccion =  $reg["Direccion"]; 
			$telefono =  $reg["telefono"]; 						
			$pagina = $reg["pagina"];
			$cve_Empresa = $reg["cve_Empresa"];	   					
?>
Member Avatar
PoA
Posting Whiz in Training
234 posts since Jul 2004
Reputation Points: 12 [?]
Q&As Helped to Solve: 11 [?]
Skill Endorsements: 0 [?]
 
0
 

Your local machine does not show because you have turned off the error reporting. Anyway try the below code. Do let me know whether it works.

<?php
    require('conexion2.php');
    $SQLEmpresa= "SELECT empresa.cve_Empresa, Nombre, Direccion, pagina, telefono 
	             FROM empresa, empresa_Categoria  
		WHERE ".$_GET['cve_Categoria']." = empresa_Categoria.cve_Categoria 
		 AND empresa_Categoria.cve_Empresa = empresa.cve_Empresa";
    $rsEmpresa = mysql_query($SQLEmpresa,$conexion);
	while ($reg = mysql_fetch_array($rsEmpresa))//line 107
	   {		
			$nombre =  $reg["Nombre"]; 
			$direccion =  $reg["Direccion"]; 
			$telefono =  $reg["telefono"]; 						
			$pagina = $reg["pagina"];
			$cve_Empresa = $reg["cve_Empresa"]
} // You forget to close while loop					
?>
Member Avatar
janzaldo
Newbie Poster
3 posts since Jul 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

tnx for your time the error was i had the table empresa_Categoria whit upper case
and the name of the table is empresa_categoria with lower case
tnx a lot for your time

Member Avatar
Gary King
PHP/vBulletin Guru
414 posts since Nov 2003
Reputation Points: 37 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
Team Colleague
 
0
 

Yep, character case is extremely important both in MySQL and in PHP - I suggest most of the time to keep things in lowercase ;)

Member Avatar
malishan
Newbie Poster
2 posts since Jun 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource...this is the same bug i am fed of it...please do some help...I am trying to retrieve record from the database from sa_settings table but to retrieve the information related to product, i have to go to the table cards to look up for ProductID in it....i got one record from the database but why the hell that While loop search for another record when I dont have any other record in the table...this is sucking my mind and i am trying to get over it for the last two days...hope u guyz could help me out of it..

<DIV id="<?PHP echo ($_GET['ID']); ?>">
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr align="center" valign="top">
 <td height="16" colspan="3" bgcolor="#FFFFFF"><strong><font color="#000066" size="1" face="Tahoma" style="bold"><?PHP echo ($_GET['ID']); ?></font></strong></td>
                                              </tr>
                                              <tr align="center" valign="top"> 
                                                <td height="16" colspan="3" bgcolor="#FFFFFF">&nbsp;</td>
                                              </tr>
                                              <?php
                $User_name=$_GET['ID']; 
              $sql="select * from sa_settings where username='$User_name'";
              $result = mysql_query ($sql) or die("Query error: ". mysql_error());
              $counter=0;
              mysql_num_rows($result);
              if(mysql_num_rows($result)>0)
               {
               while($rs=mysql_fetch_array($result))
                {
                $counter=$counter+1;
                $PID=$rs['ProductID'];
                $COMM=$rs['Commision'];
                $sql="select * from cards WHERE CardID=$PID";
                $result=mysql_query($sql);
             ?>
                                              <tr valign="top"> 
                                                <td height="16" bgcolor="#FFFFFF"><?php echo $result['CardName']; ?>&nbsp;</td>
                                                <td width="134" height="16" bgcolor="#FFFFFF"><?php echo $result['Price']; ?></td>
                                                <td width="151" bgcolor="#FFFFFF"><input name="Commision<?php echo $counter; ?>" type="text" id="Commision<?php echo $counter; ?>" value="<?php echo $COMM; ?>" size="7"></td>
                                              </tr>
                                              <?php
               }

                }           
             ?>

the schema for the two tables are as follows;

cards table
-------------
CardID
CardName
Price
Status






sa_settings table
-------------------
usID
username
ProductID --> CardID
Commision

I want to retrieve CardName from cards table, I get one such result but there is no second result and While loop is again entering in to its body to look up for the record...why??????

I have tested the queries on mySQL engine and they are giving me only one result per record. What is wrong with the code...

Member Avatar
malishan
Newbie Poster
2 posts since Jun 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

This is the snapshot of my output that I am getting with the following error string...

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /data/12/1/9/102/1172754/user/1246647/htdocs/MasterAgent/viewsuperagent.php on line 240

and I have this on line 240

while($rs=mysql_fetch_array($result))


Owais

Owais


Why this second text box is comming....

Member Avatar
DGStudios
Light Poster
31 posts since Mar 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

check your query. If you get the not supplied valid arguement, 99.9% of the time. the problem is in your query. Echo out your query and check it to make sure that is working properly. This can be done any place that you can free-form a MySQL query in your database. Check to make sure it is workign properly.

Member Avatar
dkoch0452
Newbie Poster
1 post since Jun 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Having the same issue, using a previous page as a template which does connect, so I would think there are no issues there. When i cut and paste the sql statement into phpmyadmin it works fine. It is a rather lengthy sql statement and complicated using temorary tables.

$statistics = mysql_query("CREATE TEMPORARY TABLE set1 (
id VARCHAR(5) NOT NULL
, score VARCHAR(5) NOT NULL DEFAULT 0
, totalscore VARCHAR(5) NOT NULL NOT NULL DEFAULT 0
, time timestamp NOT NULL
, setid VARCHAR(5) NOT NULL
) ;

INSERT INTO set1
(id, score, totalscore, time, setid)
SELECT
users.id, statistics.score, statistics.totalscore, MAX(statistics.time), sets.id
FROM users, statistics, sets
WHERE users.id = statistics.userid
AND statistics.setid = sets.id
AND sets.id = '1'
GROUP BY users.id;


CREATE TEMPORARY TABLE set2 (
id VARCHAR(5) NOT NULL
, score VARCHAR(5) NOT NULL DEFAULT 0
, totalscore VARCHAR(5) NOT NULL NOT NULL DEFAULT 0
, time timestamp NOT NULL
, setid VARCHAR(5) NOT NULL
) ;

INSERT INTO set2
(id, score, totalscore, time, setid)
SELECT
users.id, statistics.score, statistics.totalscore, MAX(statistics.time), sets.id
FROM users, statistics, sets
WHERE users.id = statistics.userid
AND statistics.setid = sets.id
AND sets.id = '2'
GROUP BY users.id;

CREATE TEMPORARY TABLE set3 (
id VARCHAR(5) NOT NULL
, score VARCHAR(5) NOT NULL DEFAULT 0
, totalscore VARCHAR(5) NOT NULL NOT NULL DEFAULT 0
, time timestamp NOT NULL
, setid VARCHAR(5) NOT NULL
) ;

INSERT INTO set3
(id, score, totalscore, time, setid)
SELECT
users.id, statistics.score, statistics.totalscore, MAX(statistics.time), sets.id
FROM users, statistics, sets
WHERE users.id = statistics.userid
AND statistics.setid = sets.id
AND sets.id = '3'
GROUP BY users.id;

CREATE TEMPORARY TABLE set4 (
id VARCHAR(5) NOT NULL
, score VARCHAR(5) NOT NULL DEFAULT 0
, totalscore VARCHAR(5) NOT NULL NOT NULL DEFAULT 0
, time timestamp NOT NULL
, setid VARCHAR(5) NOT NULL
) ;

INSERT INTO set4
(id, score, totalscore, time, setid)
SELECT
users.id, statistics.score, statistics.totalscore, MAX(statistics.time), sets.id
FROM users, statistics, sets
WHERE users.id = statistics.userid
AND statistics.setid = sets.id
AND sets.id = '4'
GROUP BY users.id;

CREATE TEMPORARY TABLE set5 (
id VARCHAR(5) NOT NULL
, score VARCHAR(5) NOT NULL DEFAULT 0
, totalscore VARCHAR(5) NOT NULL NOT NULL DEFAULT 0
, time timestamp NOT NULL
, setid VARCHAR(5) NOT NULL
) ;

INSERT INTO set5
(id, score, totalscore, time, setid)
SELECT
users.id, statistics.score, statistics.totalscore, MAX(statistics.time), sets.id
FROM users, statistics, sets
WHERE users.id = statistics.userid
AND statistics.setid = sets.id
AND sets.id = '5'
GROUP BY users.id;

CREATE TEMPORARY TABLE set6 (
id VARCHAR(5) NOT NULL
, score VARCHAR(5) NOT NULL DEFAULT 0
, totalscore VARCHAR(5) NOT NULL NOT NULL DEFAULT 0
, time timestamp NOT NULL
, setid VARCHAR(5) NOT NULL
) ;

INSERT INTO set6
(id, score, totalscore, time, setid)
SELECT
users.id, statistics.score, statistics.totalscore, MAX(statistics.time), sets.id
FROM users, statistics, sets
WHERE users.id = statistics.userid
AND statistics.setid = sets.id
AND sets.id = '6'
GROUP BY users.id;

CREATE TEMPORARY TABLE set7 (
id VARCHAR(5) NOT NULL
, score VARCHAR(5) NOT NULL DEFAULT 0
, totalscore VARCHAR(5) NOT NULL NOT NULL DEFAULT 0
, time timestamp NOT NULL
, setid VARCHAR(5) NOT NULL
) ;

INSERT INTO set7
(id, score, totalscore, time, setid)
SELECT
users.id, statistics.score, statistics.totalscore, MAX(statistics.time), sets.id
FROM users, statistics, sets
WHERE users.id = statistics.userid
AND statistics.setid = sets.id
AND sets.id = '7'
GROUP BY users.id;

SELECT D.last, D.first,
D.dept, D.duties, D.doh,
set1.setid, set1.score, set1.totalscore, set1.time,
set2.setid, set2.score, set2.totalscore, set2.time,
set3.setid, set3.score, set3.totalscore, set3.time,
set4.setid, set4.score, set4.totalscore, set4.time,
set5.setid, set5.score, set5.totalscore, set5.time,
set6.setid, set6.score, set6.totalscore, set6.time,
set7.setid, set7.score, set7.totalscore, set7.time
FROM directory2 AS D
LEFT JOIN users AS U ON D.last = U.last_name
LEFT JOIN set1 USING (id)
LEFT JOIN set2 USING (id)
LEFT JOIN set3 USING (id)
LEFT JOIN set4 USING (id)
LEFT JOIN set5 USING (id)
LEFT JOIN set6 USING (id)
LEFT JOIN set7 USING (id)
WHERE D.dept = '01 - Atlanta'
GROUP BY last
".$limiting);

while($astatistics = mysql_fetch_array($statistics)){
AND IT DIES RIGHT HERE. HAVE TRIED THIS A FEW DIFFERENT WAYS AND IT WILL NOT EXECUTE THE QUERY - ANY IDEAS?
Actually this is a a series of sql statments separated by semicolons, it works in phpmyadmin , should they be separate sql statements?

Member Avatar
mrterry
Newbie Poster
1 post since Sep 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I am also getting this error ? Any help would greatly be appreciated.

Thanks MrTerry

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/bluestar/public_html/forum/admin/admin_ideas.php on line 94

<?php
/***************************************************************************
 *                              admin_ideas.php
 *                            -------------------
 *   begin                : Saturday, Jul 28, 2007
 *   copyright            : (C) 2007 Funender.com
 *   email                : [email]admin@funender.com[/email]
 *
 *   $Id:lang_admin_ideas.php,v 1.0.1 2007/07/28 23:24:01 FuNEnD3R Exp $
 *
 *
 ***************************************************************************/


define('IN_PHPBB', 1);

if( !empty($setmodules) )
{
	$file = append_sid("admin_ideas.$phpEx").'&amp;mode=view';
	$module['General']['Admin_Ideas'] = $file;
	return;
}

//
// Let's set the root dir for phpBB
//
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
require($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin_ideas.' . $phpEx);
include($phpbb_root_path . 'includes/functions_selects.'.$phpEx);


     $status = array("0" => $lang['pending'],
					 "1" => $lang['testing'],
					 "2" => "<font color=\"green\">".$lang['done']."</font>",
					 "3" => "<font color=\"red\">".$lang['denied']."</font>");

if($_GET["mode"] == "view" || $_POST["mode"] == "view") {

				$template->set_filenames(array(
					"body" => "admin/admin_ideas.tpl")
					);
		
				$template->assign_vars(array(
								 "ADD_NEW_IDEA" => $lang['Add_New_Idea'],
								 "SAVE" => $lang['Save'],
								 "TESTING" => $lang['Testing'],
								 "COMPLETE" => $lang['Complete'],
								 "DENY" => $lang['Deny'],
								 "FILTER" => $lang['Filter'],
								 "EDIT" => $lang['Edit'],
								 "DELETE" => $lang['Delete'],
								 "CURRENTLY" => $lang['Currently_Working'],
								 "ADDED" => $lang['New_Idea_Added'],
								 "WISH" => $lang['Do_Not_Wish'],
								 
								 "F_NONE" => $lang['Filter_none'],
								 "F_PENDING" => $lang['Filter_pending'],
								 "F_TESTING" => $lang['Filter_testing'],
								 "F_DONE" => $lang['Filter_done'],
								 "F_DENIED" => $lang['Filter_denied'],
								 
								 "S_DATE" => $lang['Status_Date'],
								 "S_USER" => $lang['Status_User'],
								 "S_IDEA" => $lang['Status_Idea'],
								 "S_STATUS" => $lang['Status_Status'],
								 "S_OPTIONS" => $lang['Status_Options'],
									
								 "B_WRITE" => $lang['Admin_Written'],
								 "B_SUBMIT" => $lang['Add_Submit'],
	
	                             "U_IDEA_ACTION" => append_sid("admin_ideas.$phpEx"),
                        	     "U_IDEA_ALL"  => append_sid("?mode=view"),
							     "U_IDEA_ORD1" => append_sid("?mode=view&amp;orderby=0"),
							     "U_IDEA_ORD2" => append_sid("?mode=view&amp;orderby=1"),
							     "U_IDEA_ORD3" => append_sid("?mode=view&amp;orderby=2"),
							     "U_IDEA_ORD4" => append_sid("?mode=view&amp;orderby=3"))
								 );
	

	$orderby = $_GET[orderby];
	if($orderby != '')
	{
		$res = mysql_query("SELECT * FROM phpbb_newideas WHERE idea_status='$orderby' ORDER BY idea_id DESC");
	}
	else
	{
	   $res = mysql_query("SELECT * FROM phpbb_newideas ORDER BY idea_status ASC, idea_id DESC");
	}
	
	while($row = mysql_fetch_array($res)) {
		$resb = mysql_query("SELECT username FROM phpbb_users WHERE user_id = '".$row["user_id"]."'");
		$rowb = mysql_fetch_array($resb);
		
		if($row["idea_status"] == 1) {
			$opt1 = append_sid("?mode=status&amp;idea_id=".$row["idea_id"]."&amp;status=0");
		} else {
			$opt1 = append_sid("?mode=status&amp;idea_id=".$row["idea_id"]."&amp;status=1");
		}
				  $vars = array("IDEA_TIME"   => date("m/d/Y", $row["idea_time"]),
							    "IDEA_TEXT"   => nl2br(htmlspecialchars($row["idea_text"], HTML_ENTITIES)),
							    "IDEA_STATUS" => $status[$row["idea_status"]],
							    "USER_NAME"   => htmlspecialchars($rowb["username"], HTML_ENTITIES),
	
							    "IDEA_OPT1"   =>  $opt1,
							    "IDEA_OPT2"   =>  append_sid("?mode=status&amp;idea_id=".$row["idea_id"]."&amp;status=2"),
							    "IDEA_OPT3"   =>  append_sid("?mode=status&amp;idea_id=".$row["idea_id"]."&amp;status=3"),
							    "IDEA_OPT4"   =>  append_sid("?mode=edit&amp;idea_id=".$row["idea_id"]),
							    "IDEA_OPT5"   =>  append_sid("?mode=del&amp;idea_id=".$row["idea_id"]));
				$template->assign_block_vars("idearow", $vars);
			}
			$template->pparse("body");
}

if($_POST["save_idea"]) {
	   $idea_text = $_POST["idea_text"];
	   if(strlen($idea_text) <= 0) {
			$message = $lang['Enter_Message'] . "<br /><br /><a href=\"javascript:history.go(-1)\">". sprintf($lang['Click_Here_Go_Back'] . "</a>");
			 message_die(GENERAL_MESSAGE, $message);
	   }
	
	   $sql = "INSERT INTO phpbb_newideas (idea_text, idea_time, user_id) 
	           VALUES('".$_POST["idea_text"]."', '".time()."', '".$userdata["user_id"]."')";
			   
		if( !$result = $db->sql_query($sql) )
		{
		      message_die(GENERAL_ERROR, "Couldn't insert into idea table", "", __LINE__, __FILE__, $sql);
		}
		
		   $message = $lang['Idea_Saved'] . "<br /><br /><a href=\"".append_sid("admin_ideas.$phpEx?mode=view")."\">". sprintf($lang['Click_Here_Go_Back'] . "</a>");
		    message_die(GENERAL_MESSAGE, $message);
}

if($_GET["mode"] == "status") {
	   $sql = "UPDATE phpbb_newideas SET idea_status = '".$_GET["status"]."' WHERE idea_id = '".$_GET["idea_id"]."'";
		if( !$result = $db->sql_query($sql) )
		{
			 message_die(GENERAL_ERROR, "Couldn't update idea table", "", __LINE__, __FILE__, $sql);
		}
		
		  $message = $lang['Status_Updated'] . "<br /><br /><a href=\"".append_sid("admin_ideas.$phpEx?mode=view")."\">". sprintf($lang['Click_Here_Go_Back'] . "</a>");
		   message_die(GENERAL_MESSAGE, $message);
}


if($_GET["mode"] == "del") {
	   $sql = "DELETE FROM phpbb_newideas WHERE idea_id = '".$_GET["idea_id"]."'";
		if( !$result = $db->sql_query($sql) )
		{
			 message_die(GENERAL_ERROR, "Couldn't update idea table", "", __LINE__, __FILE__, $sql);
		}
		
		 $message = $lang['Idea_Deleted'] . "<br /><br /><a href=\"".append_sid("admin_ideas.$phpEx?mode=view")."\">". sprintf($lang['Click_Here_Go_Back'] . "</a>");
		  message_die(GENERAL_MESSAGE, $message);
}

if($_GET["mode"] == "edit") {
	   $sql = "SELECT idea_text, idea_id FROM phpbb_newideas WHERE idea_id = '".$_GET["idea_id"]."'";
		if( !$result = $db->sql_query($sql) )
		{
			 message_die(GENERAL_ERROR, "Couldn't update idea table", "", __LINE__, __FILE__, $sql);
		}
		
	$row = mysql_fetch_array($result);
	
	         $template->set_filenames(array(
	         "body" => "admin/admin_ideas_edit.tpl")
	         );
			 
	        $template->assign_vars(array(
			                     "EDIT_IDEA" => $lang['Edit_Idea'],
								 "SAVE" => $lang['Save'],
	                             "IDEA_TEXT" => htmlspecialchars($row["idea_text"], HTML_ENTITIES), 
	                             "IDEA_ID" => $row["idea_id"],
								 
								 "B_WRITE" => $lang['Admin_Written'],
								 "B_SUBMIT" => $lang['Add_Submit'],
								 
								 "U_IDEA_ACTION" => append_sid("admin_ideas.$phpEx"))
								 );
	        $template->pparse("body");
}

if($_POST["save_edit_idea"]) {
	   $sql = "UPDATE phpbb_newideas SET idea_text = '".$_POST["idea_text"]."' WHERE idea_id = '".$_POST["idea_id"]."'";
		if( !$result = $db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, "Couldn't update idea table", "", __LINE__, __FILE__, $sql);
		}
		
		$message = $lang['Idea_Edited'] . "<br /><br /><a href=\"".append_sid("admin_ideas.$phpEx?mode=view")."\">". sprintf($lang['Click_Here_Go_Back'] . "</a>");
		 message_die(GENERAL_MESSAGE, $message);
}


include('./page_footer_admin.'.$phpEx);

?>
Member Avatar
fareed7865
Newbie Poster
1 post since Dec 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi
I am developing a simple login system for college project.
Facing difficulty in getting this code working.

It is showing the same error:

"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pakistan/public_html/checklogin.php on line 11 Login unsuccessful!Either your UserID or your Password is incorrect.

Please put the right UserID or Password, otherwise register yourself Back" 

here is the code:

<?php
session_start();

    $conn = mysql_connect('localhost', 'user', 'password');

    $result = mysql_query('select * from Customer where 
    UserID = "'. $_POST[UserID].'" And Password = "'. $_POST[Password].'"');
    $row = mysql_fetch_array($result);
    if ($row[UserID]==$_POST['UserID'])
    {
    echo 'Login successful';
    echo 'Please click on';
    echo "</br><a href=\"Tshirt.php\"> T-Shirt</a>";
    }
    else
    {
    echo '<blink><font color=\”red\”>Login unsuccessful!'; 
    echo 'Either your UserID or your Password is incorrect.';
    echo '</br>Please put the right UserID or Password, otherwise register yourself';
    echo "</br><a href=\"Shopping.php\"> Back</a>";
    }
?>

can anybody tell me where the problem is?
thanks

Member Avatar
nav33n
Purple hazed!
3,894 posts since Nov 2007
Reputation Points: 472 [?]
Q&As Helped to Solve: 381 [?]
Skill Endorsements: 20 [?]
Team Colleague
Featured
 
0
 
$user_id=$_POST['UserID'];
$password=$_POST['Password'];
$query="select * from Customer where
UserID = '$user_id' and Password = '$password'";
echo $query;
$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.

Member Avatar
luqyan
Newbie Poster
1 post since May 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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)
Member Avatar
ShawnCplus
Code Monkey
1,564 posts since Apr 2005
Reputation Points: 456 [?]
Q&As Helped to Solve: 269 [?]
Skill Endorsements: 39 [?]
Team Colleague
 
0
 

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.

Member Avatar
chirag87
Newbie Poster
1 post since Oct 2009
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-2
 

$rsEmpresa = mysql_query($SQLEmpresa,$conexion) or die(mysql_error());
//add the text shown in BOLD, this will atleast display what error you are having

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

<?php
    require('conexion2.php');
    $SQLEmpresa= "SELECT empresa.cve_Empresa, Nombre, Direccion, pagina, telefono 
	             FROM empresa, empresa_Categoria  
		WHERE ".$_GET['cve_Categoria']." = empresa_Categoria.cve_Categoria 
		 AND empresa_Categoria.cve_Empresa = empresa.cve_Empresa";
    $rsEmpresa = mysql_query($SQLEmpresa,$conexion);
	$reg = array();
-->line 107	while ($reg = mysql_fetch_array($rsEmpresa))
	   {		
			$nombre =  $reg["Nombre"]; 
			$direccion =  $reg["Direccion"]; 
			$telefono =  $reg["telefono"]; 						
			$pagina = $reg["pagina"];
			$cve_Empresa = $reg["cve_Empresa"];	   					
?>
Member Avatar
network18
Practically a Master Poster
643 posts since Sep 2009
Reputation Points: 15 [?]
Q&As Helped to Solve: 78 [?]
Skill Endorsements: 0 [?]
 
-1
 

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

Member Avatar
srinivas88
Light Poster
48 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-1
 

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

<?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/][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!="")
{
$found++;
echo "&nbsp;&nbsp;&nbsp;&nbsp; ".$sri."->".$sri."<br />";
}
}
if($found!=0)
{echo "Found ".$found." results!";}
mysql_close($con)
?>
[code/]

Member Avatar
venkat0904
Junior Poster
186 posts since Oct 2009
Reputation Points: 1 [?]
Q&As Helped to Solve: 21 [?]
Skill Endorsements: 0 [?]
 
0
 

your query doesnt seems right to me... try this

$query = "SELECT * FROM administrator WHERE".$_POST[searchby]."like  '%".$_POST[query]."%'";
$result = mysql_query($query);

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

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

<?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)
?>
Member Avatar
srinivas88
Light Poster
48 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

@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.....

Member Avatar
venkat0904
Junior Poster
186 posts since Oct 2009
Reputation Points: 1 [?]
Q&As Helped to Solve: 21 [?]
Skill Endorsements: 0 [?]
 
0
 

ohhh m so sorry... didn't include the spaces.. my bad.
just add a space after "where" clause and before "like".
should be--

$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!!

@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.....

Member Avatar
srinivas88
Light Poster
48 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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...

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article