Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Returning mysql array values via function.

    Hello,

    I'm trying to return mysql values via function.

    basically I have these two:

    function create() {

    $data=load_user();

    echo $data[0]['uname'];
    }



    function load_user() {

    $queryData[]="";
    while($row = mysql_fetch_array($result)){

    $queryData[]['uname']=$row[0];
    $queryData[]['email']=$row[1];
    }

    return $queryData;

    }

    any help? Someone suggested me those code but it doesn't seem to work

    -aaron

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,323
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    You don't have a mysql query in there anywhere.

    $result = mysql_query("select * from <tablename>");

    Put that above your mysql_fetch_array line.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • Users who have thanked tangoforce for this post:

    ag1060 (08-27-2011)

  • #3
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ya I can't believe I missed something simple as that. Thanks tangoforce...everything's working smoothly

    -aaron


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •