Display user data from database by Session in PHP MYSQL [duplicate]
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>';
}?>
php mysql sql session
marked as duplicate by Funk Forty Niner
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.
add a comment |
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>';
}?>
php mysql sql session
marked as duplicate by Funk Forty Niner
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.
add a comment |
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>';
}?>
php mysql sql session
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
php mysql sql session
asked Jan 1 at 10:21
DaránDarán
207
207
marked as duplicate by Funk Forty Niner
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
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.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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);
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
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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);
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
add a comment |
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);
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
add a comment |
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);
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);
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
add a comment |
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
add a comment |