Page 2 of 2

Re: Warning: mysql_fetch_assoc(): supplied argument is not a

Posted: Tue Aug 04, 2009 11:05 am
by jackpf
No, in the first script. I can't see it being set anywhere.

Re: Warning: mysql_fetch_assoc(): supplied argument is not a

Posted: Tue Aug 04, 2009 12:47 pm
by tobimichigan
SidewinderX wrote:$_GET is an array, $_GET["pfno"] is some value. What value are you expecting it to have? I was trying to make sense of your SQL query. You are selecting pfno your database where pfno=$_GET["pfno"], thus $user['pfno'] equals $_GET["pfno"] rendering your query quite useless.
jackpf wrote:Also, you're selecting where pfno=$pfno, but I don't see where $pfno has been set. Don't you mean $username?

And exactly - you're assing $_SESSION['pfno'] to 'pfno' what's the point?

I think you need to go back and read your own code.
So what do I do to correct these errors and get what is needed?

Re: Warning: mysql_fetch_assoc(): supplied argument is not a

Posted: Tue Aug 04, 2009 1:28 pm
by jackpf
I think you need to go back over your script and check the general logic of how stuff is running.

Also, check how many rows are being returned from mysql_query(), and check to see if sessions are actually being set etc...

Stuff like that.

Re: Warning: mysql_fetch_assoc(): supplied argument is not a

Posted: Tue Aug 04, 2009 3:35 pm
by tobimichigan
tobimichigan wrote:
SidewinderX wrote:$_GET is an array, $_GET["pfno"] is some value. What value are you expecting it to have? I was trying to make sense of your SQL query. You are selecting pfno your database where pfno=$_GET["pfno"], thus $user['pfno'] equals $_GET["pfno"] rendering your query quite useless.
jackpf wrote:Also, you're selecting where pfno=$pfno, but I don't see where $pfno has been set. Don't you mean $username?

And exactly - you're assing $_SESSION['pfno'] to 'pfno' what's the point?

I think you need to go back and read your own code.
So what do I do to correct these errors and get what is needed?
Are u giving up already Sir Jack?

Re: Warning: mysql_fetch_assoc(): supplied argument is not a

Posted: Tue Aug 04, 2009 5:43 pm
by SidewinderX
The real question is, have you given up? It is pretty apparent you have no idea what you are doing, so while you waiting for someone to hand you an answer (which doesn't happen very often) it may be beneficial to read up on MySQL. I would try to help, but you still have yet to answer my question.

Re: Warning: mysql_fetch_assoc(): supplied argument is not a

Posted: Wed Aug 05, 2009 5:02 am
by tobimichigan
SidewinderX wrote:The real question is, have you given up? It is pretty apparent you have no idea what you are doing, so while you waiting for someone to hand you an answer (which doesn't happen very often) it may be beneficial to read up on MySQL. I would try to help, but you still have yet to answer my question.
What question? And yes, I may not have an idea of what I'm doing but at least I'm open to learning and discovering new ideas.

Re: Warning: mysql_fetch_assoc(): supplied argument is not a

Posted: Thu Aug 06, 2009 7:57 am
by jackpf
Yes, it is indeed good to learn.

But this forum is for helping people who have persistently tried to solve their own problem, and have been unable to do so.

It's not for teaching people PHP or MySQL or whatever. That's what books and tutorials are for.

No offense.

What in the world is $_GET["pfno"]?
And I think that's the question SidewinderX was referring to.

Re: Warning: mysql_fetch_assoc(): supplied argument is not a

Posted: Thu Aug 06, 2009 9:10 am
by straightman
I mean, i think it is clear what the man wants to do, the query supposedly retrieves the full name of the person according to a posted variable that he receives from the login form and sends to the db.

On the one side, what version of php are you working with? if you are over 6.0 you need to rewrite the name of the function as mysqli_whatever follows, (note the extra i), that alone would cause the error you are getting.

A second aspect:

I dont understand why you are doing this: $user = mysql_fetch_assoc($pfno);

Instead of $pfno, you are supposed to enter there $result, which is what you got from $mysql_query

so, work in that direction.

Regards

Alvaro

=================================================================================




tobimichigan wrote:Hi there code gurus,
Please Chief McInfo, Sir Jack and other honorable code gurus, I need a sharp pointer as to why this error keeps coming up:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\www\Members.Arena\actions\Members_Area.php on line 24

Code: Select all

 
<?php
session_start();
 
if (!$_SESSION["pfno"])
{
//user not logged in, redirect to login page
header("Location:Login.php");
}
include("cn.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
 
<body>
<a href="Members_Area.php">Members Area</a> | <a href="Edit_Profile.php">Edit Profile</a> | <a href="Reports.php">Reports</a> | <a href="Logout.php">Logout</a>
<?php
$pfno=$_GET["pfno"];
$user=mysql_query("Select * From user_table where pfno='$pfno'");
//$result=mysql_query($query,$link);
$user = mysql_fetch_assoc($pfno);
//Display Member Information
echo ("<p>Welcome PFNO: ".$_SESSION["pfno"]);
echo ("<p>Logged in:  " .date("m/d/Y", $_SESSION["valid_time"]));
?>
</body>
</html>
 
I am actually trying to retrieve unique members information from multiple tables say table_a and perhaps table_b as well.
Please kindly point to where "Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\www\Members.Arena\actions\Members_Area.php on line 24" is coming from.

line 24=$user = mysql_fetch_assoc($pfno);

Re: Warning: mysql_fetch_assoc(): supplied argument is not a

Posted: Thu Aug 06, 2009 2:12 pm
by SidewinderX
@jackpf - Yes that is the question I am referring to.

@straightman - From what I understood in this post he wants to retrieve pfno from his database - but according to what criterion? Currently is doing a
SELECT `pfno` FROM `user_table` WHERE` pfno`='$pfno'
where $pfno is $_GET['pfno']. If this is what he wants, he can save himself a query and simply use $_GET['pfno'] or is it $_SESSION['pfno']? I doubt that is what he wants, which is why I was trying to determine the value of $_GET['pfno'] as jackpf pointed out.

Also why would it matter if he is using mysql_ or mysqli_? Is mysql_ being depreciated or something?

Re: Warning: mysql_fetch_assoc(): supplied argument is not a

Posted: Fri Aug 07, 2009 5:26 am
by straightman
Hello

1) well, as per mysql, and relatives, will not work from php 6.0 onwards, it has to have the additional 'i' . I got that message myself before some other times.

2) hmm, i dont think he just wants to echo the name of the person as he logs in, so as to welcome Alvaro, but retrieve more or the full data refering to that logged in visitor, so i dont see how all that would be kept and how in a session.

regards

A

-=================================================================================================