943,558 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 114921
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Aug 4th, 2004
0

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

Expand 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


PHP Syntax (Toggle Plain Text)
  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. ?>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
janzaldo is offline Offline
3 posts
since Jul 2004
Aug 5th, 2004
0

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

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]<?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
?>[/PHP]
PoA
Reputation Points: 19
Solved Threads: 9
Posting Whiz in Training
PoA is offline Offline
234 posts
since Jul 2004
Aug 5th, 2004
0

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

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
janzaldo is offline Offline
3 posts
since Jul 2004
Aug 23rd, 2004
0

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

Yep, character case is extremely important both in MySQL and in PHP - I suggest most of the time to keep things in lowercase
Team Colleague
Reputation Points: 53
Solved Threads: 5
PHP/vBulletin Guru
Gary King is offline Offline
360 posts
since Nov 2003
Jun 3rd, 2007
0

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

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...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
malishan is offline Offline
2 posts
since Jun 2007
Jun 3rd, 2007
0

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

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....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
malishan is offline Offline
2 posts
since Jun 2007
Jun 6th, 2007
0

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

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.
Reputation Points: 10
Solved Threads: 3
Light Poster
DGStudios is offline Offline
31 posts
since Mar 2006
Jun 14th, 2007
0

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

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?
Last edited by dkoch0452; Jun 14th, 2007 at 3:47 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dkoch0452 is offline Offline
1 posts
since Jun 2007
Sep 6th, 2007
0

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

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 : admin@funender.com
*
* $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);

?>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mrterry is offline Offline
1 posts
since Sep 2007
Dec 7th, 2007
0

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

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fareed7865 is offline Offline
1 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: SMTP limitation?
Next Thread in PHP Forum Timeline: Please Help...New to MySQL





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC