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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Echo table results after cookie authentication

    Ok, its four in the morning this end and my brain is fried.
    Been battling with a piece of code and cannot find my mistake...

    HERE IS THE CODE:
    _______________________

    <?php

    // database settings
    $db_host = 'localhost:3309';
    $db_user = 'south-com';
    $db_pass = '@kevin@llano@';
    $db_name = 'micaportal-new';
    $db_prefix = 'fusion_';
    define('DB_PREFIX', 'fusion_');

    /*Collect current username from database*/
    $cookie_1 = $_COOKIE["fusion_user"];
    $pos = strpos($cookie_1,".");
    $user = substr($cookie_1,0,$pos);
    $db_connect = @mysql_connect($db_host, $db_user, $db_pass);
    $db_select = @mysql_select_db($db_name);
    $sql = "SELECT user_name FROM fusion_users WHERE user_id = ".$user;

    $result = @mysql_query($sql);

    if (!$result) {
    echo mysql_error();
    return false;
    }

    $rows = mysql_fetch_assoc($result);
    $user_name = $rows["user_name"];

    /* List Table limited to current user name */

    //query the database
    /* AND THIS IS WHERE THINGS GO WRONG */

    $query = "SELECT * FROM supplier_payments WHERE store_code = ".$user_name;


    //fetch the results / convert results into an array

    while ($rows = mysql_fetch_array($query));

    $store_code = $rows["store_code"];

    echo "$store_code";

    endwhile;


    ?>

    ____________________

    I CANNOT GET THE THINK TO ONLY DISPLAY THE SELECTED RECORDS ON SCREEN

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,683
    Thanks
    25
    Thanked 656 Times in 655 Posts
    Change
    PHP Code:
    $sql "SELECT user_name FROM fusion_users WHERE user_id = ".$user
    To:
    PHP Code:
    $sql "SELECT user_name FROM fusion_users WHERE user_id = $user"
    If your still having trouble I'd look at
    PHP Code:
    $cookie_1 $_COOKIE["fusion_user"];
    $pos strpos($cookie_1,".");
    $user substr($cookie_1,0,$pos); 
    cause I don't know what all you put into the cookie and that may or may not be correct. Use
    PHP Code:
    echo $user
    to see if it is.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

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