/    Sign up×
Community /Pin to ProfileBookmark

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

Hi

i make function in dreamweaver and i send $id which is generated from repeated region

[CODE]<?php
function getname($id)
{
do{
if($row_rs_father[‘id’] == $id)
echo $row_rs_father[‘name’]; // error comes here !!!
}while ($row_rs_father = mysql_fetch_assoc($rs_father));
}
?>[/CODE]

any help?

thanks in advance.

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@aj_nscJan 02.2008 — whats $rs_father? It should be the result of a query, but where's the query? post all of your code.
Copy linkTweet thisAlerts:
@secoauthorJan 03.2008 — yes $rs_father is the result and the query is

$query_rs_father = "SELECT id, name FROM persons";

$rs_father = mysql_query($query_rs_father, $family_con) or die(mysql_error());

$row_rs_father = mysql_fetch_assoc($rs_father);
Copy linkTweet thisAlerts:
@secoauthorJan 03.2008 — by the way this result generated by dreamweaver and i make the function getname to search the results on my own

when i debug the code i see the $id send to the function correctly every time but $row_rs_father is null every time and this line gives the warrning on the page
Copy linkTweet thisAlerts:
@TheRaveJan 03.2008 — How is $row_rs_father parsed to the function?

It either needs to be parsed as a parameter (like $id) or it needs to be accessed globally:

[code=php]<?php global $row_rs_father ?>[/code]
Copy linkTweet thisAlerts:
@aj_nscJan 03.2008 — I think you mean $rs_father needs to be set globally.
Copy linkTweet thisAlerts:
@TheRaveJan 03.2008 — Yeah, sorry.
Copy linkTweet thisAlerts:
@spadmoreJan 03.2008 — You probably have a variable scope issue here. That or an invalid connection or result of the query.

  • - Shelon Pamdore
  • ×

    Success!

    Help @seco spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.7,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...