Display user data from database by Session in PHP MYSQL [duplicate]












0
















This question already has an answer here:




  • How can I prevent SQL injection in PHP?

    28 answers



  • Reference - What does this error mean in PHP?

    32 answers




I am trying to display all the user information on the user session key. When the user logs in with their email, all of there relevant information is pulled from the database depending on the user email and displayed via the session key. However, I don't know exactly how to do it. I have used the session key 'user' and the table I am trying to retrieve the information from is "client".



The error I am getting is "Fatal error: Uncaught Error: Call to a member function bind_param()", so I believe it is either the SQL statement or the bind parameter. The logic behind the code may be incorrect and may require additional lines.



Any help would be greatly appreciated!



            <?php
$user = $_SESSION["user"];
$con=new mysqli("localhost:3308","root","","fypdatabase");
$st=$con->prepare("select * from client where email=".$_SESSION['user']."");
$st->bind_param("s", $user);
$st->execute();
$rs=$st->get_result();
while($row=$rs->fetch_assoc())
{
echo '<div class="w3-container w3-third">
<p><strong>'.$row["name"].'</strong></p>
<p>'.$row["age"].'</p>
<p>'.$row["sex"].'</p>
<p>'.$row["weight"].' Weeks</p>
<p>'.$row["height"].'</p>
</div>';
}?>









share|improve this question













marked as duplicate by Funk Forty Niner mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 1 at 15:28


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.























    0
















    This question already has an answer here:




    • How can I prevent SQL injection in PHP?

      28 answers



    • Reference - What does this error mean in PHP?

      32 answers




    I am trying to display all the user information on the user session key. When the user logs in with their email, all of there relevant information is pulled from the database depending on the user email and displayed via the session key. However, I don't know exactly how to do it. I have used the session key 'user' and the table I am trying to retrieve the information from is "client".



    The error I am getting is "Fatal error: Uncaught Error: Call to a member function bind_param()", so I believe it is either the SQL statement or the bind parameter. The logic behind the code may be incorrect and may require additional lines.



    Any help would be greatly appreciated!



                <?php
    $user = $_SESSION["user"];
    $con=new mysqli("localhost:3308","root","","fypdatabase");
    $st=$con->prepare("select * from client where email=".$_SESSION['user']."");
    $st->bind_param("s", $user);
    $st->execute();
    $rs=$st->get_result();
    while($row=$rs->fetch_assoc())
    {
    echo '<div class="w3-container w3-third">
    <p><strong>'.$row["name"].'</strong></p>
    <p>'.$row["age"].'</p>
    <p>'.$row["sex"].'</p>
    <p>'.$row["weight"].' Weeks</p>
    <p>'.$row["height"].'</p>
    </div>';
    }?>









    share|improve this question













    marked as duplicate by Funk Forty Niner mysql
    Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Jan 1 at 15:28


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





















      0












      0








      0









      This question already has an answer here:




      • How can I prevent SQL injection in PHP?

        28 answers



      • Reference - What does this error mean in PHP?

        32 answers




      I am trying to display all the user information on the user session key. When the user logs in with their email, all of there relevant information is pulled from the database depending on the user email and displayed via the session key. However, I don't know exactly how to do it. I have used the session key 'user' and the table I am trying to retrieve the information from is "client".



      The error I am getting is "Fatal error: Uncaught Error: Call to a member function bind_param()", so I believe it is either the SQL statement or the bind parameter. The logic behind the code may be incorrect and may require additional lines.



      Any help would be greatly appreciated!



                  <?php
      $user = $_SESSION["user"];
      $con=new mysqli("localhost:3308","root","","fypdatabase");
      $st=$con->prepare("select * from client where email=".$_SESSION['user']."");
      $st->bind_param("s", $user);
      $st->execute();
      $rs=$st->get_result();
      while($row=$rs->fetch_assoc())
      {
      echo '<div class="w3-container w3-third">
      <p><strong>'.$row["name"].'</strong></p>
      <p>'.$row["age"].'</p>
      <p>'.$row["sex"].'</p>
      <p>'.$row["weight"].' Weeks</p>
      <p>'.$row["height"].'</p>
      </div>';
      }?>









      share|improve this question















      This question already has an answer here:




      • How can I prevent SQL injection in PHP?

        28 answers



      • Reference - What does this error mean in PHP?

        32 answers




      I am trying to display all the user information on the user session key. When the user logs in with their email, all of there relevant information is pulled from the database depending on the user email and displayed via the session key. However, I don't know exactly how to do it. I have used the session key 'user' and the table I am trying to retrieve the information from is "client".



      The error I am getting is "Fatal error: Uncaught Error: Call to a member function bind_param()", so I believe it is either the SQL statement or the bind parameter. The logic behind the code may be incorrect and may require additional lines.



      Any help would be greatly appreciated!



                  <?php
      $user = $_SESSION["user"];
      $con=new mysqli("localhost:3308","root","","fypdatabase");
      $st=$con->prepare("select * from client where email=".$_SESSION['user']."");
      $st->bind_param("s", $user);
      $st->execute();
      $rs=$st->get_result();
      while($row=$rs->fetch_assoc())
      {
      echo '<div class="w3-container w3-third">
      <p><strong>'.$row["name"].'</strong></p>
      <p>'.$row["age"].'</p>
      <p>'.$row["sex"].'</p>
      <p>'.$row["weight"].' Weeks</p>
      <p>'.$row["height"].'</p>
      </div>';
      }?>




      This question already has an answer here:




      • How can I prevent SQL injection in PHP?

        28 answers



      • Reference - What does this error mean in PHP?

        32 answers








      php mysql sql session






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 1 at 10:21









      DaránDarán

      207




      207




      marked as duplicate by Funk Forty Niner mysql
      Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Jan 1 at 15:28


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by Funk Forty Niner mysql
      Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Jan 1 at 15:28


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          1 Answer
          1






          active

          oldest

          votes


















          1














          You have not a param request in query (you have wrongly added the php var $_SESSION['user'] )
          You should use a ? for param



          $st=$con->prepare("select * from client where email= ? ");
          $st->bind_param("s", $user);





          share|improve this answer
























          • absolute legend worked right away thank you!!

            – Darán
            Jan 1 at 10:28











          • @Darán well if my answer is right please mark it as accepted ...(past 15 minutes) see how here meta.stackexchange.com/questions/5234/…

            – scaisEdge
            Jan 1 at 10:48


















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You have not a param request in query (you have wrongly added the php var $_SESSION['user'] )
          You should use a ? for param



          $st=$con->prepare("select * from client where email= ? ");
          $st->bind_param("s", $user);





          share|improve this answer
























          • absolute legend worked right away thank you!!

            – Darán
            Jan 1 at 10:28











          • @Darán well if my answer is right please mark it as accepted ...(past 15 minutes) see how here meta.stackexchange.com/questions/5234/…

            – scaisEdge
            Jan 1 at 10:48
















          1














          You have not a param request in query (you have wrongly added the php var $_SESSION['user'] )
          You should use a ? for param



          $st=$con->prepare("select * from client where email= ? ");
          $st->bind_param("s", $user);





          share|improve this answer
























          • absolute legend worked right away thank you!!

            – Darán
            Jan 1 at 10:28











          • @Darán well if my answer is right please mark it as accepted ...(past 15 minutes) see how here meta.stackexchange.com/questions/5234/…

            – scaisEdge
            Jan 1 at 10:48














          1












          1








          1







          You have not a param request in query (you have wrongly added the php var $_SESSION['user'] )
          You should use a ? for param



          $st=$con->prepare("select * from client where email= ? ");
          $st->bind_param("s", $user);





          share|improve this answer













          You have not a param request in query (you have wrongly added the php var $_SESSION['user'] )
          You should use a ? for param



          $st=$con->prepare("select * from client where email= ? ");
          $st->bind_param("s", $user);






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 1 at 10:25









          scaisEdgescaisEdge

          95.8k105072




          95.8k105072













          • absolute legend worked right away thank you!!

            – Darán
            Jan 1 at 10:28











          • @Darán well if my answer is right please mark it as accepted ...(past 15 minutes) see how here meta.stackexchange.com/questions/5234/…

            – scaisEdge
            Jan 1 at 10:48



















          • absolute legend worked right away thank you!!

            – Darán
            Jan 1 at 10:28











          • @Darán well if my answer is right please mark it as accepted ...(past 15 minutes) see how here meta.stackexchange.com/questions/5234/…

            – scaisEdge
            Jan 1 at 10:48

















          absolute legend worked right away thank you!!

          – Darán
          Jan 1 at 10:28





          absolute legend worked right away thank you!!

          – Darán
          Jan 1 at 10:28













          @Darán well if my answer is right please mark it as accepted ...(past 15 minutes) see how here meta.stackexchange.com/questions/5234/…

          – scaisEdge
          Jan 1 at 10:48





          @Darán well if my answer is right please mark it as accepted ...(past 15 minutes) see how here meta.stackexchange.com/questions/5234/…

          – scaisEdge
          Jan 1 at 10:48





          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith