1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP/MYSQLi downline builder

Discussion in 'PHP & Perl' started by nallard, Apr 22, 2015.

  1. nallard

    nallard Newbie

    Joined:
    Apr 22, 2015
    Messages:
    2
    Likes Received:
    0
    First post in this website so bear with me. I'm also new to php coding. I've been banging my head against this code for a while now it seems so simple but yet it's giving me such problems and I'm not sure its my code at this point or something not setup correctly with the mysqli database itself. Here is the header and the code that I'm trying to create a downline builder with for my four corners site any suggestions would be helpful. <?php session_start();require ('./Checklogin.php');
    $con=mysqli_connect("localhost","username","password","DB");
    if(mysqli_connect_errno()){
    echo "Failed to connect to the database" . mysqli_connect_error();
    }
    ?>
    <!DOCTYPE html>
    <html>

    <h2>Step 2 - Join from the link below:</h2>
    <?php

    $id = $_SESSION['$id'];
    $sql = mysqli_query("SELECT 'refferalid' FROM Users WHERE id= '$id'");
    $result = $con->query($sql);
    $result_id = $result["refferalid"];
    $fourcornerssql = mysqli_query("SELECT 'fourcorners' FROM Users WHERE id= '$result_id'");
    $fourcorners = $con->query($fourcornerssql);
    $fourcorners_id = $fourcorners["fourcorners"];



    echo' link=$fourcorners_id .

    $con->close();
    ?>
     
  2. MrBlue

    MrBlue Senior Member

    Joined:
    Dec 18, 2009
    Messages:
    974
    Likes Received:
    680
    Occupation:
    Web/Bot Developer
    First off, welcome to BHW.

    Second, you should always wrap your code when posting like this:
    Code:
    Your code here...
    
    Third, you could try using the PDO driver library instead of MySQLi.
    Code:
    https://php.net/manual/en/pdo.drivers.php
    IMHO it is a lot easier to work with.


    Lastly, take a look at your error_log file. It may give you an indication as to why your code is failing.
     
    • Thanks Thanks x 1
  3. nallard

    nallard Newbie

    Joined:
    Apr 22, 2015
    Messages:
    2
    Likes Received:
    0
    thank you and sorry about the missing code tags. I'll have to see if I have PDO as an available option with a hosted site I access through c panel. I ended up figuring out my issue and ran into another such is the learning process.
     
  4. BTSTU

    BTSTU Newbie

    Joined:
    May 17, 2015
    Messages:
    14
    Likes Received:
    1
    Use a framework man. It's much easier since all the groundwork is built for you already. Check out laravel. They have authentication built in, encryption, billing, etc.