Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    661
    Rep Power
    0

    Question Why mysqli_stmt_bind_result Failing To Yield Results Properly ?


    Folks, the following code is supposed to pull results from my db tbl.
    It manages to pull some column data while fails on others. Error reporting on. I have not made any errors on the $variable naming. Nor, any errors on column naming. I get no error.
    But for some reason, the script manages to pull some column data while others not. What is the mystery behind this new problem ?
    For proof of my claim, check the 3rd ELSE that looks like the following by looking at my comment in the code:

    PHP Code:
    else
        {
            
    //FOLLOWING ECHOES CHECK WHETHER $RESULTS GOT PULLED OR NOT
            
    echo 'Results yielded $id:'; echo "$id<br>"//THIS IS GETTING YIELDED
            
    echo 'Results yielded $date_and_time:'; echo "$date_and_time<br>"//WHY IS THIS FAILING TO GET YIELDED ?
            
    echo 'Results yielded $recipient_username:'; echo "$recipient_username<br>"//THIS IS GETTING YIELDED
            
    echo 'Results yielded $sender_username:'; echo "$sender_username<br>"//WHY IS THIS FAILING TO GET YIELDED ?
            
    echo 'Results yielded $message:'; echo "$message<br>"//WHY IS THIS FAILING TO GET YIELDED ?
        

    My point is, it should either work 100% or not work atall and show errors. And not manage to pull some column data while others not. Strange!

    Full Code:
    PHP Code:
    <?php 

    //Required PHP Files. 
    include 'config.php'
    include 
    'header.php'

    //Check if User is already logged-in or not. Get the login_check() FUNCTION to check. 
    if (login_check() === FALSE
    {
        
    //Redirect User to Log-in Page after 2 secs. 
        
    header("refresh:2; url=login.php"); 
        exit(); 

    else 

        
    $user $_SESSION["user"]; 
        
        
    $id $_SESSION["id"]; 
        
    $account_activation_status $_SESSION["account_activation_status"]; 
        
    $id_video_verification_status $_SESSION["id_video_verification_status"]; 
        
    $id_video_verification_url $_SESSION["id_video_verification_url"]; 
        
    $sponsor_username $_SESSION["sponsor_username"]; 
        
    $recruits_number $_SESSION["recruits_number"]; 
        
    $on_day_number_on_7_days_wish_list $_SESSION["on_day_number_on_7_days_wish_list"]; 
        
    $primary_website_domain $_SESSION["primary_website_domain"]; 
        
    $primary_website_email $_SESSION["primary_website_email"]; 
        
    $username $_SESSION["username"]; 
        
    $first_name $_SESSION["first_name"]; 
        
    $middle_name $_SESSION["middle_name"]; 
        
    $surname $_SESSION["surname"]; 
        
    $gender $_SESSION["gender"]; 
        
    $age_range $_SESSION["age_range"]; 
        
    $religion $_SESSION["religion"]; 
        
    $marital_status $_SESSION["marital_status"]; 
        
    $working_status $_SESSION["working_status"]; 
        
    $profession $_SESSION["profession"]; 
        
        
    $recipient_username $user;

        
    ?> 
        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional/EN"> 
        <html> 
        <head> 
          <meta content="text/html; charset=ISO-8859-1"  http-equiv="content-type"> 
        <title><?php $user ?>Notices in <?php $server_time ?> time.</title>
        </head> 
        <body> 
        <br> 
        <center><span style="font-weight: bold;"><?php $user ?>Notices in <?php $server_time ?> time.</span></center> 
        <br> 
        <br> 
        
    <?php 
        
    if (!$conn)
    {
        
    $error mysqli_connect_error();
        
    $errno mysqli_connect_errno();
        print 
    "$errno$error\n";
        exit();
    }

    $recipient_username $user;
    $query "SELECT id,date_and_time,recipient_username,sender_username,message FROM notices WHERE recipient_username = ?";

    if (
    $stmt mysqli_prepare($conn$query)) {

        
    /* bind param */
        
    mysqli_stmt_bind_param($stmt,'s',$recipient_username);
        
        
    /* execute statement */
        
    mysqli_stmt_execute($stmt);    

        
    /* bind result variables */
        
    $result mysqli_stmt_bind_result($stmt,$id,$date_and_time,$recipient_username,$sender_username,$message);
        
    //$result = mysqli_stmt_store_result($stmt);
        //mysqli_free_result($result);
        
        
    $rows_num mysqli_stmt_num_rows($stmt);
        
        
    ?> 
        <?php 
        
    if ($rows_num<1){
            echo 
    "Rows yielded: 0<br>";
            echo 
    "$user$user<br>";
            echo 
    "recipient_username: $recipient_username<br>";        
        }
        else
        {
            echo 
    "number of rows yielded: $rows_num<br>";        
        }
        if (!
    $result){
            echo 
    "Results yielded: 0<br>";
            echo 
    "$user<br>";
            echo 
    "recipient_username: $recipient_username<br>";    
            
        }
        else
        {
            
    //FOLLOWING ECHOES CHECK WHETHER $RESULTS GOT PULLED OR NOT
            
    echo 'Results yielded $id:'; echo "$id<br>"//THIS IS GETTING YIELDED
            
    echo 'Results yielded $date_and_time:'; echo "$date_and_time<br>"//WHY IS THIS FAILING TO GET YIELDED ?
            
    echo 'Results yielded $recipient_username:'; echo "$recipient_username<br>"//THIS IS GETTING YIELDED
            
    echo 'Results yielded $sender_username:'; echo "$sender_username<br>"//WHY IS THIS FAILING TO GET YIELDED ?
            
    echo 'Results yielded $message:'; echo "$message<br>"//WHY IS THIS FAILING TO GET YIELDED ?
        
    }
        
    ?>
        <table width="1500" border="0" cellpadding="5" cellspacing="2" bgcolor="#666666"> 
        <?php if($rows_num) {?> 
        <tr name="headings"> 
        <td bgcolor="#FFFFFF" name="column-heading_submission-number">Submission Number</td> 
        <td bgcolor="#FFFFFF" name="column-heading_logging-server-date-&-time">Date & Time in <?php $server_time ?></td> 
        <td bgcolor="#FFFFFF" name="column-heading_username">To</td> 
        <td bgcolor="#FFFFFF" name="column-heading_gender">From</td> 
        <td bgcolor="#FFFFFF" name="column-heading_age-range">Notice</td> 
        </tr> 
        
        <?php while($row mysqli_stmt_fetch($result)){ ?>     
        <tr name="user-details"> 
        <td bgcolor="#FFFFFF" name="submission-number"><?php echo $row['id']; ?></td> 
        <td bgcolor="#FFFFFF" name="logging-server-date-&-time"><?php echo $row['date_and_time']; ?></td> 
        <td bgcolor="#FFFFFF" name="username"><?php echo $row['recipient_username']; ?></td> 
        <td bgcolor="#FFFFFF" name="gender"><?php echo $row['sender_username']; ?></td> 
        <td bgcolor="#FFFFFF" name="age-range"><?php echo $row['message']; ?></td> 
        </tr> 
        <?php ?> 
        <tr name="pagination"> 
        <td colspan="10" bgcolor="#FFFFFF"> Result Pages: 
        <?php 
        
            
    if($rows_num <= $page_size
            { 
                echo 
    "Page 1";  
            } 
            else 
            { 
                for(
    $i=1;$i<=$page_count;$i++) 
                echo 
    "<a href=\"{$_SERVER['PHP_SELF']}?page_number={$i}\">{$i}</a>  "
            }     
            
    ?>     
        </td> 
        </tr> 
        <?php } else { ?> 
        <tr> 
        <td bgcolor="FFFFFF">No record found! Try another time.</td> 
        </tr> 
        <?php }?> 
        </table> 
        <br> 
        <br> 
        <center><span style="font-weight: bold;"><?php $user ?>Notices in <?php $server_time ?> time.</span></center> 
        <br> 
        <br> 
    </div> 
    <br> 
    </body> 
    </html> 
    <?php 

    //close statement
    mysqli_stmt_close($stmt);
    }

    //close connection
    mysqli_close($conn);

    }

    ?>
    See attachment.
    Attached Images
    Last edited by UniqueIdeaMan; February 26th, 2018 at 04:01 AM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2016
    Posts
    125
    Rep Power
    65
    One Last time.

    //FOLLOWING ECHOES CHECK WHETHER $RESULTS GOT PULLED OR NOT
    NO, this section of code does not display data being fetched from the result set. It is just displaying the current values in those variables.

    $id has a value because you are setting it at about line 18 in your code. $recipient_username has a value because you are setting it at about line 38 in your code.

    These variables do not have values from the result set because you have not executed any fetch statement at that point in the code.

    And if you are wondering why your code using mysqli_stmt_num_rows()/$num_rows and mysqli_stmt_fetch() are not working, it's because you are not using those correctly. Until you somehow go, learn, and retain information from the php.net documentation on how to use the specific php statements that are in your code, you will never be able to write code that works. You are just randomly putting things together based on what you mistakenly believe they should look like and want someone else to do your thinking for you and tell you what keys to push to fix the current problem, when you have correctly used these things before. You are not learning from the things that worked before and are repeatedly wasting our time as the result.

    BTW - you should be seeing some php errors, but because the php code that's throwing the errors is inside of a html table, but not inside of a table element that gets rendered and displayed, the errors should all be lumped together outside of the html table or in the 'view source' in your browser.

    This is starting to feel the same as trying to help DoubleDee (long time php help forum members will understand.)
    Last edited by DSmabismad; February 26th, 2018 at 05:56 AM.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2017
    Location
    Worldwide
    Posts
    45
    Rep Power
    44
    This is starting to feel the same as trying to help DoubleDee
    groundhog-day-bill-murra.jpg
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,418
    Rep Power
    631
    Suggested reading for the OP.

    Comments on this post

    • benanamen agrees : one of the best links ever! Thanks for the Post.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    661
    Rep Power
    0
    Originally Posted by DSmabismad
    One Last time.



    NO, this section of code does not display data being fetched from the result set. It is just displaying the current values in those variables.

    $id has a value because you are setting it at about line 18 in your code. $recipient_username has a value because you are setting it at about line 38 in your code.

    These variables do not have values from the result set because you have not executed any fetch statement at that point in the code.

    And if you are wondering why your code using mysqli_stmt_num_rows()/$num_rows and mysqli_stmt_fetch() are not working, it's because you are not using those correctly. Until you somehow go, learn, and retain information from the php.net documentation on how to use the specific php statements that are in your code, you will never be able to write code that works. You are just randomly putting things together based on what you mistakenly believe they should look like and want someone else to do your thinking for you and tell you what keys to push to fix the current problem, when you have correctly used these things before. You are not learning from the things that worked before and are repeatedly wasting our time as the result.

    BTW - you should be seeing some php errors, but because the php code that's throwing the errors is inside of a html table, but not inside of a table element that gets rendered and displayed, the errors should all be lumped together outside of the html table or in the 'view source' in your browser.

    This is starting to feel the same as trying to help DoubleDee (long time php help forum members will understand.)

    Thanks man!
    It's clear now why $id and $recipient_username were echoing values.
    In short, you're saying my PREP STMTs are totally failing to fetch the rows. Fetching has failed before the echoes.
    So, I should fetch first and then see what gets echoed. Ok, I understand you now.
    As for mysqli_stmt_num_rows(), I thought I had it correct. Thanks for bringing it to my attention that I'm making a mistake here as I was at a loss. I'll look more into this now.
    One question, from line 138-146, I see that I fetched first and then tried echoing again but this time through html. And so, the fetch should have worked and echoed the values through html unless I'm fetching incorrectly. I'm keeping an eye on this issue and experimenting right now.
    If you still think I'm not on the right track then say so.

    Cheers!

    EDIT: Been playing around with php manual for few days now and got nowhere ...
    PHP: mysqli_stmt::fetch - Manual
    PHP Manual: mysqli_stmt_fetch
    PHP: mysqli_stmt::bind_result - Manual

    Those are only 10% of the tutorials I've been dealign with and so I have checked the manual before opening this thread.
    Last edited by UniqueIdeaMan; February 27th, 2018 at 08:21 AM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    661
    Rep Power
    0
    One question, if I want to output the results from mysql tbl through html then should I fetch the tbl query results through mysqli_stmt_fetch() or mysqli_stmt_get_result() ?
    And, should I not use the echo but printf instead to output the resuls through html like I'm trying to do in my original post ?
    I came across this link few days back and so switched from get_result to fetch:
    https://stackoverflow.com/questions/...-vs-get-result

    Notice that, most links I come across use the oop style over procedural and that is why I can't make any progress through them samples.
    This experiment with mysqli_stmt_fetch() and mysqli_stmt_bind_result with printf did not work.
    PHP Code:
        <?php while($row mysqli_stmt_fetch($stmt)){ ?>     
        <tr name="user-details"> 
        <td bgcolor="#FFFFFF" name="submission-number"><?php printf("%s %s\n"$id); ?></td> 
        <td bgcolor="#FFFFFF" name="logging-server-date-&-time"><?php printf("%s %s\n"$date_and_time); ?></td> 
        <td bgcolor="#FFFFFF" name="username"><?php printf("%s %s\n"$recipient_username); ?></td> 
        <td bgcolor="#FFFFFF" name="gender"><?php printf("%s %s\n"$sender_username); ?></td> 
        <td bgcolor="#FFFFFF" name="age-range"><?php printf("%s %s\n"$age_range); ?></td> 
        </tr> 
        <?php ?>
    I have rearranged my code and now clearly see the data from the tbl is not getting fetched:
    PHP Code:
    <?php 

    //Required PHP Files. 
    include 'config.php'
    include 
    'header.php'

    //Check if User is already logged-in or not. Get the login_check() FUNCTION to check. 
    if (login_check() === FALSE
    {
        
    //Redirect User to Log-in Page after 2 secs. 
        
    header("refresh:2; url=login.php"); 
        exit(); 

    else 

        
    $user $_SESSION["user"]; 
        
        
    $id $_SESSION["id"]; 
        
    $account_activation_status $_SESSION["account_activation_status"]; 
        
    $id_video_verification_status $_SESSION["id_video_verification_status"]; 
        
    $id_video_verification_url $_SESSION["id_video_verification_url"]; 
        
    $sponsor_username $_SESSION["sponsor_username"]; 
        
    $recruits_number $_SESSION["recruits_number"]; 
        
    $on_day_number_on_7_days_wish_list $_SESSION["on_day_number_on_7_days_wish_list"]; 
        
    $primary_website_domain $_SESSION["primary_website_domain"]; 
        
    $primary_website_email $_SESSION["primary_website_email"]; 
        
    $username $_SESSION["username"]; 
        
    $first_name $_SESSION["first_name"]; 
        
    $middle_name $_SESSION["middle_name"]; 
        
    $surname $_SESSION["surname"]; 
        
    $gender $_SESSION["gender"]; 
        
    $age_range $_SESSION["age_range"]; 
        
    $religion $_SESSION["religion"]; 
        
    $marital_status $_SESSION["marital_status"]; 
        
    $working_status $_SESSION["working_status"]; 
        
    $profession $_SESSION["profession"]; 
        
        
    $recipient_username $user;

        
    ?> 
        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional/EN"> 
        <html> 
        <head> 
          <meta content="text/html; charset=ISO-8859-1"  http-equiv="content-type"> 
        <title><?php $user ?>Notices in <?php $server_time ?> time.</title>
        </head> 
        <body> 
        <br> 
        <center><span style="font-weight: bold;"><?php $user ?>Notices in <?php $server_time ?> time.</span></center> 
        <br> 
        <br> 
        
    <?php 
        
    if (!$conn)
    {
        
    $error mysqli_connect_error();
        
    $errno mysqli_connect_errno();
        print 
    "$errno$error\n";
        exit();
    }

    $recipient_username $user;
    $query "SELECT id,date_and_time,recipient_username,sender_username,message FROM notices WHERE recipient_username = ?";

    if (
    $stmt mysqli_prepare($conn$query)) {

        
    /* bind param */
        
    mysqli_stmt_bind_param($stmt,'s',$recipient_username);
        
        
    /* execute statement */
        
    mysqli_stmt_execute($stmt);    

        
    /* bind result variables */
        
    $result mysqli_stmt_bind_result($stmt,$id,$date_and_time,$recipient_username,$sender_username,$message);
        
    //$result = mysqli_stmt_store_result($stmt);
        //mysqli_free_result($result);
        
        
    $rows_num mysqli_stmt_num_rows($stmt);
        
        
    /*
        //Total number of pages records are spread-over 
        $page_count = 10; 
        $page_size = ceil($rows_num / $page_count); 
        //Get the Page Number, Default is 1 (First Page) 
        $page_number = $_GET["page_number"]; 
        if ($page_number == "") $page_number = 1; 
            $offset = ($page_number -1) * $page_size; 
            
            $query .= " limit {$offset},{$page_size}"; 
            $result = mysqli_stmt_bind_result($stmt,$id,$date_and_time,$recipient_username,$sender_username,$message);
            //$result = mysqli_stmt_store_result($stmt);
            //mysqli_free_result($result);
        */
        
    ?> 
        <table width="1500" border="0" cellpadding="5" cellspacing="2" bgcolor="#666666"> 
        <?php if($rows_num) {?> 
        <tr name="headings"> 
        <td bgcolor="#FFFFFF" name="column-heading_submission-number">Submission Number</td> 
        <td bgcolor="#FFFFFF" name="column-heading_logging-server-date-&-time">Date & Time in <?php $server_time ?></td> 
        <td bgcolor="#FFFFFF" name="column-heading_username">To</td> 
        <td bgcolor="#FFFFFF" name="column-heading_gender">From</td> 
        <td bgcolor="#FFFFFF" name="column-heading_age-range">Notice</td> 
        </tr> 
        <?php 
        
    /*
        FORMULA: http://php.net/manual/en/mysqli-stmt.bind-result.php
        fetch values 
        while (mysqli_stmt_fetch($stmt)) {
            printf("%s %s\n", $col1, $col2);
        }
        */
        
    ?>
        <?php while($row mysqli_stmt_fetch($stmt)){ ?>     
        <tr name="user-details"> 
        <td bgcolor="#FFFFFF" name="submission-number"><?php printf("%s %s\n"$id); ?></td> 
        <td bgcolor="#FFFFFF" name="logging-server-date-&-time"><?php printf("%s %s\n"$date_and_time); ?></td> 
        <td bgcolor="#FFFFFF" name="username"><?php printf("%s %s\n"$recipient_username); ?></td> 
        <td bgcolor="#FFFFFF" name="gender"><?php printf("%s %s\n"$sender_username); ?></td> 
        <td bgcolor="#FFFFFF" name="age-range"><?php printf("%s %s\n"$age_range); ?></td> 
        </tr> 
        <?php ?> 
        <tr name="pagination"> 
        <td colspan="10" bgcolor="#FFFFFF"> Result Pages: 
        <?php 
        
            
    if($rows_num <= $page_size
            { 
                echo 
    "Page 1";  
            } 
            else 
            { 
                for(
    $i=1;$i<=$page_count;$i++) 
                echo 
    "<a href=\"{$_SERVER['PHP_SELF']}?page_number={$i}\">{$i}</a>  "
            }     
            
    ?>     
        </td> 
        </tr> 
        <?php } else { ?> 
        <tr> 
        <td bgcolor="FFFFFF">No record found! Try another time.</td> 
        </tr> 
        <?php }?> 
        </table> 
        <br> 
        <br> 
        <center><span style="font-weight: bold;"><?php $user ?>Notices in <?php $server_time ?> time.</span></center> 
        <br> 
        <br> 
    </div> 
    <br> 
        <?php 
        
    if ($rows_num<1){
            echo 
    "Rows yielded: 0<br>";
            echo 
    "$user$user<br>";
            echo 
    "recipient_username: $recipient_username<br>";        
        }
        else
        {
            echo 
    "number of rows yielded: $rows_num<br>";        
        }
        if (!
    $stmt){
            echo 
    "Results yielded: 0<br>";
            echo 
    "$user<br>";
            echo 
    "recipient_username: $recipient_username<br>";    
            
        }
        else
        {
            
    //FOLLOWING ECHOES CHECK WHETHER $RESULTS GOT PULLED OR NOT
            
    echo 'Results yielded $id:'; echo "$id<br>"//THIS IS GETTING YIELDED
            
    echo 'Results yielded $date_and_time:'; echo "$date_and_time<br>"//WHY IS THIS FAILING TO GET YIELDED ?
            
    echo 'Results yielded $recipient_username:'; echo "$recipient_username<br>"//THIS IS GETTING YIELDED
            
    echo 'Results yielded $sender_username:'; echo "$sender_username<br>"//WHY IS THIS FAILING TO GET YIELDED ?
            
    echo 'Results yielded $message:'; echo "$message<br>"//WHY IS THIS FAILING TO GET YIELDED ?        
        
    }
        
    ?>
    </body> 
    </html> 
    <?php 

    //close statement
    mysqli_stmt_close($stmt);
    }

    //close connection
    mysqli_close($conn);

    }

    ?>
    Notice the echoes on line 156 - 172:
    PHP Code:
    else
        {
            
    //FOLLOWING ECHOES CHECK WHETHER $RESULTS GOT PULLED OR NOT
            
    echo 'Results yielded $id:'; echo "$id<br>"//THIS IS GETTING YIELDED
            
    echo 'Results yielded $date_and_time:'; echo "$date_and_time<br>"//WHY IS THIS FAILING TO GET YIELDED ?
            
    echo 'Results yielded $recipient_username:'; echo "$recipient_username<br>"//THIS IS GETTING YIELDED
            
    echo 'Results yielded $sender_username:'; echo "$sender_username<br>"//WHY IS THIS FAILING TO GET YIELDED ?
            
    echo 'Results yielded $message:'; echo "$message<br>"//WHY IS THIS FAILING TO GET YIELDED ?        
        
    }
        
    ?>
    </body> 
    </html> 
    Since tbl is not yielding any results and I see I got my mysql_stmt_fetch() done and the printing on screen through html done correctly via printf then the only conclusion I can come right now to is that I got my mysqli_num_rows wrong. But saying all this, should this really hinder the fetching ?
    Last edited by UniqueIdeaMan; February 27th, 2018 at 08:50 AM.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,418
    Rep Power
    631
    Originally Posted by UniqueIdeaMan
    Notice that, most links I come across use the oop style over procedural and that is why I can't make any progress through them samples.


    That should be a hint.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    661
    Rep Power
    0
    Originally Posted by gw1500se
    That should be a hint.
    Hint to what ? I should use oop ? Can't jump to oop right now. Been working on this project by learning the required php for 12 months now using procedural style. Hence, have to complete this project with procedural style first and then look into pdo like Benanaman wants.

    EDIT: I edited my previous post.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    661
    Rep Power
    0
    Damn feature to present all column data through PREP STMTs has become a real pain up the a**e!
    But saying all this, I'm learning my flaws regarding understanding bind_result, fetch() etc. and so it is worth it for me at the end and I hope it will be worth it for you guys too one day.
    Meaning: When I finish my project and gpl it and the unemployed world make money out of sites that run my concepts (and you guys too) then you will be satisfied for "wasting your precious time" on my threads.
    Last edited by UniqueIdeaMan; February 27th, 2018 at 08:58 AM.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2016
    Posts
    125
    Rep Power
    65
    Damn feature to present all column data through PREP STMTs has become a real pain up the a**e!
    This is why you have been told multiple times to use the much simpler and more consistent php PDO extension. At least half of the database code you have now will disappear. The mysqli extension was apparently designed by someone who had never actually used php to interact with a database, and certainly not in a dynamic way. Some of the things that were added later (php 5.3) to make mysqli try to catch up with POD and be easier to use, where present in PDO from the beginning.
  20. #11
  21. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2017
    Location
    Worldwide
    Posts
    45
    Rep Power
    44
    Originally Posted by gw1500se
    Suggested reading for the OP.
    One of the best things ever posted!

    OP, you are a help vampire.
    Please read the link. As you are well aware of from my posts in the various forums you cross-post in and the PM's I have sent you over the last year, you know I am willing to help you when you put your big boy pants on and start using PDO.
    Numerous people on various fourm have pointed out your help vampire ways. The end result is that people with valuable experience and knowledge are getting burned out on helping you. Follow the advice in the link and you will be welcomed with open arms on all the forums. Besides I don't want to wait forever for your big multimillion-dollar ideas to come to life. I want to be rich now.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    661
    Rep Power
    0
    Originally Posted by benanamen
    One of the best things ever posted!

    OP, you are a help vampire.
    Please read the link. As you are well aware of from my posts in the various forums you cross-post in and the PM's I have sent you over the last year, you know I am willing to help you when you put your big boy pants on and start using PDO.
    Numerous people on various fourm have pointed out your help vampire ways. The end result is that people with valuable experience and knowledge are getting burned out on helping you. Follow the advice in the link and you will be welcomed with open arms on all the forums. Besides I don't want to wait forever for your big multimillion-dollar ideas to come to life. I want to be rich now.
    "Besides I don't want to wait forever for your big multimillion-dollar ideas to come to life. I want to be rich now"
    Ha! Ha! Ha! That's the spirit OLD MAN! That is exactly my point! The sooner I release my ventures the sooner the unemployed, house-wives, bankrupts, homeless, people dillusioned of life (5 groups of people), get back on their feet.
    If I jump on the pdo band wagon right this instant then it will take me a few months to master or learn enough and get to the point I am with mysqli. That means, you, me, other programmers and the 5 groups of people will have to wait another quarter year.
    Plus, I'm not sure I'd be alive back then. Not well. And so, I want to get my work out on the open asap. Therefore, once this "display all tble results via PREP STMT on page (using mysqli procedural)" is out of the way then I can release my work and others can derive ideas behind my concepts and make a change to the world when I'm no longer around (if I no longer live).

    The Vampire Nonsense
    Does he ask the same, tired questions others ask?
    Everyone asks questions others have asked once upon a time.

    Does he clearly lack the ability or inclination to ask the almighty Google?
    I ask and sometimes SERPs present links from stackoverflow and when I find my answers there then I don't bother the forums. Else, I do.
    This did help a little but not all:
    https://stackoverflow.com/questions/...-vs-get-result
    Now, if I did not search the weakling google then how did I find that link ?

    Does he refuse to take the time to ask coherent, specific questions?
    Bull ....
    My questions are very specific. Infact, if a page I'm working on has 3 issues then I open 3 threads to ask on 3 different issues. Eg.
    How To Display All Records From Tbl Using PREP STMT ?
    Why mysqli_stmt_bind_result Failing To Yield Results Properly ?
    Converting Pagination Procedural Style Code To PREP STMT
    The above threads are all related to displaying tbl column data via PREP STMT. Since, I tried using different ways (one after the other when one did not work, eg. bind_result, get_result, fetch(), etc.) to achieve the same goal then instead of asking 3 different questions on 3 different php functions I opened 3 different threads. Now, how specific can you get more than that ?

    Does he think helping him must be the high point of your day?
    If I thought that way I'd be bumping my threads everyday when I saw no replies within 12hrs. How many threads of mine have I bumped ?
    But, I did used to think, you guys would come to the rescue. ALWAYS. You guys did. And the other forums too. But, I only stick to 2 forums now. This one most as I get most of my answers answered here.

    Is he obviously just waiting for some poor, well-intentioned person to do all his thinking for him?
    No, I don't expect others to do the thinking. I do the thinking and when I come across a point I don't know how to implement it then I bug others as if it is my GOD- GIVEN RIGHT! Lol! If I was building a script for my own comemrcial gain then I won't pester you guys to help me for free. I'd rather pay you guys or someone to do it. But because thse projects I'm working on with php are projects to help the public masses (me be the good Samaritan) I tried taking all the responsibility on my shoulders all by myself and now find myself drowning. And so thought, others from the public, who are capable to help (php programmers), can chime in and try helping the public through my concepts and projects by lending a hand in my php learning by providing me with sample codes to speeden-up my php learning. After-all, the php programmers are part of the public community. No harm in them helping now and then. Why take all the GLORY ALL for myself ?
    In such a case, when tutorials aren't enough, I just ask for code samples to use as a FORMULA to learn the feature.
    For example, I read on PREP STMT but the php manual sample wasn't enough. Mlukack89 from sitepoint.com forum showed me an example how to implement the PREP STMT on the registration.php. From his example I learnt how to prepare and bind results related to do with the SELCTING and INSERTING.
    PHP Code:
    //Select Username and Email to check against Mysql DB if they are already registered or not.
            
    $stmt mysqli_prepare($conn"SELECT username, primary_website_domain, primary_website_email FROM users WHERE username = ? OR primary_website_domain = ? OR primary_website_email = ?");
            
    mysqli_stmt_bind_param($stmt'sss'$registration_username$registration_primary_website_domain$registration_primary_website_email);
            
    mysqli_stmt_execute($stmt); 
    PHP Code:
    $stmt mysqli_prepare($conn,"INSERT INTO users(account_activation_status,account_activation_code,id_video_verification_status,on_day_number_on_7_days_wish_list,sponsor_username,recruits_number,username,password,primary_website_domain,primary_website_email,first_name,middle_name,surname,gender,age_range,marital_status,working_status,profession) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
            
    mysqli_stmt_bind_param($stmt,'iiiisissssssssssss',$registration_account_activation_status,$registration_account_activation_code,$registration_id_video_verification_status,$registration_on_day_number_on_7_days_wish_list,$registration_sponsor_username,$registration_recruits_number,$registration_username,$registration_hashed_password,$registration_primary_website_domain,$registration_primary_website_email,$registration_first_name,$registration_middle_name,$registration_surname,$registration_gender,$registration_age_range,$registration_marital_status,$registration_working_status,$registration_profession);
            
    mysqli_stmt_execute($stmt); 
    The above are not his exact code as I changed them after learning the "way to do them" from him.
    Now, did I bother anyone to add the PREP STMT on the login.php ? No. Since it uses the same method to do the SELECTING and INSERTING I knew how to do it.
    But, I did not know how to do the PREP STMT for the account_activation link and so Kicken here was nice enough to show me an example.
    Again, I changed his code to my requirement. Note how the $_GET have been placed. Was a little puzzled how to do that so Kicken's sample helped.
    And note that, the following code uses both mysqli_stmt_execute($stmt) && mysqli_stmt_fetch($stmt) as I did not know that was possible. Do 2 things at the same time, I mean.
    If you look at the previous 2 samples then you'll see always the mysqli_stmt_execute($stmt) was done and not the mysqli_stmt_fetch($stmt) along with it at the same time. 2 things were not done at the same time. So, this was a good learning curve.
    Now, you understand why I bug the forums for code samples when php manual not enough or google presented links not enough. Plus google presents outdated stuffs which I never would have known had not forums like this one pointed them out. Hence, google is not my best friend. The forums are.
    Have I got my message across to you people now ?

    PHP Code:
    $stmt mysqli_prepare($conn"SELECT username, account_activation_status FROM users WHERE primary_website_email = ? AND account_activation_code = ?");
        
    mysqli_stmt_bind_param($stmt'si'$_GET["primary_website_email"],  $_GET["account_activation_code"]);
        
    mysqli_stmt_bind_result($stmt$username$account_activation_status);

        
    //Perform following if Account Activation Link was valid (Correctly had the registered email and Account Activation Code associated with it).
        
    if (mysqli_stmt_execute($stmt) && mysqli_stmt_fetch($stmt)) 
    Can you tell he really isn't interested in having his question answered, so much as getting someone else to do his work?
    If I want others to do my work then I would have told others to do the login.php, home.php, profile.php, confirm.php, verify_id.php, recruits.php, sponsors.php, browsing_histories.php and a whole lot of other pages related to do with PREP STMT. But, I did these and gonna do these all by myself. But, most of these pages require me to display all tbl results. I know how to do that without PREP STMT but I need to elarn how to do it with PREP STMT and especially how to display the results in an html tbl. Hence, bugging this forum. Once, I get a sample from someone (like I got from mlukack89 and Kicken) on one page (eg. notices.php) then I should be able to do it on the other pages with slight changes displaying results from different tbles.
    So you see, I never really get you to build my pages. I just pester you to show me a sample so I can derive the wisdom or technique (FORUMLA) behind it and use it to learn the "method". Right now, see if you can google and find a tutorial that shows you how to display results from a mysql tbl through PREP STMT (using procedural style) onto an html table where the tutorial is not outdated with html 4 samples. When you fail to find any then you will understand why I bug the forum. AND, I can PROUDLY and BOLDLY make a CLAIM that I bug the forum like a LAST RESORT.
    So, who's gonna show me an example on how to display the tbl results onto html tbl using mysqli and procedural style and PREP STMT ?
    Once that is out of the way then I should be able to finish my full project in a wks time after 12 mnths of learning, struggling, ducking & diving (so to speak).
    After that, I can move onto pdodelusions.com soon.

    I actually missed that silly vampirehelp link from gw1500se.
    I'm not ashamed to ask for help to learn to build sites based on my concepts to help the helpless people.
    When I want to learn web programming for my own personal gains ONLY (commercial gain) and not for helping the masses then I'll migrate to Python as Python I hear is much simpler to learn and the books and vid tutorials should be enough for me. I should not need the forums.
    Right now, my current projects are not really revolving around me earning the big buck using php. It's mostly to do with helping the helpless. Building platforms where the small elite won't be earning money only (rich get richer and poor get poorer). My current concepts and projects are based around, DEMOCRACY, LIBERTY, SOCIALISM, PUBLICITY and PUBLIC WELFARE. Hence, gonna GPL some of my php scripts that this forum and others have SORT of aided me build through teaching me how to code some stuffs (eg. PREP STMTs).
    Poor Catacaustic believed me for half a yr and waited this long and now gone all quiet thinking I'm a disappointment and ALL TALK TALK. I got to prove myself to him, Sedopati, Benanaman, Kicken and gw1500se. And, let's not forget the latest newcomer to my threads DSmabismad.
    I'm not all TALK TALK and a BLUFFER getting my ways with you guys here wasting your times where I really don't have anything (concepts & projects) up my sleeves. Why should I try this long with you guys like that, if it was all about getting my ways with you guys. I mean, what's the real motive here ?
    No. I'm not a BLUFFER knowing I'm talking nonsense. I'm actually onto something. But the big question now is: Am I dilussioned ? Maybe, I'm a believer in my projects but just because I am does not mean it will succeed. I could be dilussioned in love with my creations when actually they are horse cr*p. Let's see shall we ? I'd like to know the answer to that myself but we'll never know unless I finish my current project by getting over this current hurdle. And, it won't finish unless I get this issue solved asap.
    Here's something that is really gonna get you all worked-up. Been planning on competing with paypal. Been researching on crypto currencies lately. Been planning on defeating paypal for about 2-3yrs now. Once my current project is finished and it defeats facebook and twitter then I continue my 2nd project which I put on hold to compete with google. After that, I start-on the 3rd prject to compete with paypal. Or better, I'll start this 3rd one and finish the 2nd one later as the 2nd one is proving to be a real pain as it's complicated. But, I won't give-up and that's my spirit. The 4th project might be to defeat ebay. I still have not thought-up ways how to defeat ebay. But, when I put my mind to things I always come-up with a solution.

    EDIT: Now, I'm pondering whether I can come-up with a vampire mind game project that earns money for the "master minds" and NO! Clearly: I am not dislussioneD! Lol!
    Just wait a little longer and see where I go. You guys waited half a yr and so don't give-up just now 99% of the way.

    EDIT AGAIN: Just so that you don't think I am crazy trying to tackle paypal all by myself here is a clue ....
    A hacker can hack into your paypal account and spend all your balance. What is the proof you did not spend it ?
    When a customer does a credit card charge-back then you not only have to refund the payer account but paypal charges you 10% penalty for the charge back. For these loopholes people hate paypal. Me too. Read paypalsucks.com. Now, I have come-up with a solution where no hacker or fraud can ever use your payer account to pay another account. That means, as a seller account, your account will never really need to refund any payer account simply due to your account will never accept fraudulent transactions. Now, ask yourself, how will your seller account know that the transaction is not a fraud transaction ? That a hacker is not using another's account to pay you ? And that, the buyer is who he says he is. And that, the buyer is not using another's account fraudulently ? If you can find the answers to these questions and build a competing paypal site then paypal will be forced to follow your lead by updating to your features or face bankrupt.
    Now, who wants to hold his breath to see what I got up my sleeves ? If you interested then help me close this ticket asap by providing a solution to my struggle. Mein Kampf!
    Oh btw, incase someone replies that paypal is regulated by bank regulators and any Tom, **** and Harry like me can't just run a similar site then ask yourself are crypto currencies like BitCoin regulated ? Why are not they ? Been researching on that and gonna use their methods. In short, not only paypal would update copying my features but the crypto currencies too!
    You see, I am starting to become very LORDLY when it comes to thinking-up CONCEPTs to be COMPETING with the MONOPOLIES. And that, is now starting to become my NATURE.
    I won't bother too much running a paypal or google defeating competition sites (apart from a few) as I don't want to become famous. Hate publicity. Prefer privacy. I'll just release my ideas publicly and enthusiastic guys like you can run these sites and make your billions, if not trillions.
    Last edited by UniqueIdeaMan; February 28th, 2018 at 05:42 AM.
  24. #13
  25. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,920
    Rep Power
    4554
    lol...
    -- Cigars, whiskey and wild, wild women. --
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    661
    Rep Power
    0
    CORRECTION: In my last post, I said I am having trouble displaying table results using PREP STMTs. I said wrong. I actually managed to do that. I manage to display all tbl results on one page. It's the pagination I'm having trouble with. On my pages, I try displaying the results on html table but fail. That's the issue.
    For some reason, I manage to pull the tbl data when displaying all on one page (no pagination and no html table) but when I try pulling the data from mysql tbl to html tbl on a pagination page then the data pulling fails.
    The non-PREP STMT version of the pagination code however manages to display the results on html tbl. That's the ironic part. Mystery.
    Last edited by UniqueIdeaMan; February 28th, 2018 at 10:15 AM.
  28. #15
  29. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,920
    Rep Power
    4554
    Displaying in an HTML table has NOTHING to do with how you retrieve the data from MySQL and get it into PHP.

    What do you expect this to be doing, btw? Is that actually printing the values?

    <?php $server_time ?>
    If you want "pages" of data, like 10 per page, then your query should only return 10 results. How do you go about that? How do you retrieve the next 10 results? Previous 10?
    -- Cigars, whiskey and wild, wild women. --
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo