mysql - Cannot fetch array inside a function PHP -
i can't fetch array inside function can outside of function. when fetched outside function , echo out, prints out 1, inside function, using same fetch array codes , echoing out, echos null. can tell because --- symbols echos out, number 1 doesn't. i'm confused, because if worked outside function, same code should work inside function, right? unless i'm doing wrong? please help. thanks.
<?php include('connect.php'); include('username.php'); //include('functionget.php'); $boo = $_get['boo']; echo "$boo"; function getdata($select,$from,$where,$equals){ $fetch = mysql_fetch_array(mysql_query("select acceptedchallenges userlogin username = '$username'")); $fetch = $fetch['acceptedchallenges']; echo "---$fetch---"; } if($boo = 'yes'){ $acceptedchallenges = getdata("acceptedchallenges","userlogin","username",$username); $fetch = mysql_fetch_array(mysql_query("select acceptedchallenges userlogin username = '$username'")); $fetch = $fetch['acceptedchallenges']; echo "$acceptedchallenges$username$fetch"; //mysql_query("update userlogin set openchallenges = '0' username = '$username'"); //mysql_query("update userlogin set acceptedchallenges = '$acceptedchallenges' username = '$username'"); } else{ } ?>
you passing $where
instead of $username
change
function getdata($select,$from,$where,$equals){
to
function getdata($select,$from,$username,$equals){
Comments
Post a Comment