How to print image out in html, using php echo and $_SESSION variable?How can I prevent SQL injection in PHP?Convert HTML + CSS to PDF with PHP?How do I give text or an image a transparent background using CSS?How do I get PHP errors to display?How to create an HTML button that acts like a link?How do I auto-resize an image to fit a 'div' container?How can I set the default value for an HTML <select> element?How do you parse and process HTML/XML in PHP?How does PHP 'foreach' actually work?Cannot display HTML string
What is the origin of the “clerics can create water” trope?
What exactly is a web font, and what does converting to one involve?
Why are two-stroke engines nearly unheard of in aviation?
What was the deeper meaning of Hermione wanting the cloak?
Tips for remembering the order of parameters for ln?
Abilities interrupting effects on a cast card
Why are there two bearded faces wearing red hats on my stealth bomber icon?
Can a Druid Wild Shaped as a horse use Horseshoes of Speed?
Carroll's interpretation of 1-forms
Can one guy with a duplicator trigger a nuclear apocalypse?
If people's daily habits are reliable then why is the stock market so unpredictable?
Is it safe to unplug a blinking USB drive after 'safely' ejecting it?
Applications of mathematics in clinical setting
Output Distinct Factor Cuboids
Amiga 500 OCS/ECS vs Mega Drive VDP
Whence comes increasing usage of "do" for "have" in ordering food?
Should the pagination be reset when changing the order?
How can I check that parent has more than 1 child?
Who are the people reviewing far more papers than they're submitting for review?
What's the word for a student who doesn't register but goes to a class anyway?
With a 500GB SSD and a 250GB SSD is it possible to mirror a 250GB partition on the 500GB with the 250GB SSD using ZFS?
Floating Point XOR
Persuading players to be less attached to a pre-session 0 character concept
What do you call the battery slot's ends?
How to print image out in html, using php echo and $_SESSION variable?
How can I prevent SQL injection in PHP?Convert HTML + CSS to PDF with PHP?How do I give text or an image a transparent background using CSS?How do I get PHP errors to display?How to create an HTML button that acts like a link?How do I auto-resize an image to fit a 'div' container?How can I set the default value for an HTML <select> element?How do you parse and process HTML/XML in PHP?How does PHP 'foreach' actually work?Cannot display HTML string
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to print out a users image using PHP and HTML.
The user's image is saved inside the $_SESSION['usericon']
The error is on line 3.
I've tried removing the PHP tags and switched print_r out etc.
<?php
if (isset($_SESSION['userId']))
echo '<img class="img-responsive" src="img/<?php print_r($_SESSION['userIcon']); ?>">
<a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else {
?>
php html
add a comment
|
I'm trying to print out a users image using PHP and HTML.
The user's image is saved inside the $_SESSION['usericon']
The error is on line 3.
I've tried removing the PHP tags and switched print_r out etc.
<?php
if (isset($_SESSION['userId']))
echo '<img class="img-responsive" src="img/<?php print_r($_SESSION['userIcon']); ?>">
<a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else {
?>
php html
1
You are in a PHP code section already, so using<?php
inside of that again makes absolutely no sense. Please go read up on some basics of string concatenation. (We should not have to explain those here, this site is not a replacement for tutorials etc.)
– 04FS
Mar 28 at 13:45
3
You could just concat the variable, not sure if this is still the syntax (not done php since v4):echo '<img class="img-responsive" src="img/' . $_SESSION['userIcon']) . '">';
– Pete
Mar 28 at 13:47
@executable I have assigned $_SESSION['userIcon'] to a variable but, when i look at the page source now i just do this: <img class="img-responsive" src="img/$userIcon">
– Mikkel Hebel
Mar 28 at 13:54
add a comment
|
I'm trying to print out a users image using PHP and HTML.
The user's image is saved inside the $_SESSION['usericon']
The error is on line 3.
I've tried removing the PHP tags and switched print_r out etc.
<?php
if (isset($_SESSION['userId']))
echo '<img class="img-responsive" src="img/<?php print_r($_SESSION['userIcon']); ?>">
<a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else {
?>
php html
I'm trying to print out a users image using PHP and HTML.
The user's image is saved inside the $_SESSION['usericon']
The error is on line 3.
I've tried removing the PHP tags and switched print_r out etc.
<?php
if (isset($_SESSION['userId']))
echo '<img class="img-responsive" src="img/<?php print_r($_SESSION['userIcon']); ?>">
<a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else {
?>
php html
php html
edited Mar 28 at 14:06
executable
2,0682 gold badges11 silver badges27 bronze badges
2,0682 gold badges11 silver badges27 bronze badges
asked Mar 28 at 13:43
Mikkel HebelMikkel Hebel
45 bronze badges
45 bronze badges
1
You are in a PHP code section already, so using<?php
inside of that again makes absolutely no sense. Please go read up on some basics of string concatenation. (We should not have to explain those here, this site is not a replacement for tutorials etc.)
– 04FS
Mar 28 at 13:45
3
You could just concat the variable, not sure if this is still the syntax (not done php since v4):echo '<img class="img-responsive" src="img/' . $_SESSION['userIcon']) . '">';
– Pete
Mar 28 at 13:47
@executable I have assigned $_SESSION['userIcon'] to a variable but, when i look at the page source now i just do this: <img class="img-responsive" src="img/$userIcon">
– Mikkel Hebel
Mar 28 at 13:54
add a comment
|
1
You are in a PHP code section already, so using<?php
inside of that again makes absolutely no sense. Please go read up on some basics of string concatenation. (We should not have to explain those here, this site is not a replacement for tutorials etc.)
– 04FS
Mar 28 at 13:45
3
You could just concat the variable, not sure if this is still the syntax (not done php since v4):echo '<img class="img-responsive" src="img/' . $_SESSION['userIcon']) . '">';
– Pete
Mar 28 at 13:47
@executable I have assigned $_SESSION['userIcon'] to a variable but, when i look at the page source now i just do this: <img class="img-responsive" src="img/$userIcon">
– Mikkel Hebel
Mar 28 at 13:54
1
1
You are in a PHP code section already, so using
<?php
inside of that again makes absolutely no sense. Please go read up on some basics of string concatenation. (We should not have to explain those here, this site is not a replacement for tutorials etc.)– 04FS
Mar 28 at 13:45
You are in a PHP code section already, so using
<?php
inside of that again makes absolutely no sense. Please go read up on some basics of string concatenation. (We should not have to explain those here, this site is not a replacement for tutorials etc.)– 04FS
Mar 28 at 13:45
3
3
You could just concat the variable, not sure if this is still the syntax (not done php since v4):
echo '<img class="img-responsive" src="img/' . $_SESSION['userIcon']) . '">';
– Pete
Mar 28 at 13:47
You could just concat the variable, not sure if this is still the syntax (not done php since v4):
echo '<img class="img-responsive" src="img/' . $_SESSION['userIcon']) . '">';
– Pete
Mar 28 at 13:47
@executable I have assigned $_SESSION['userIcon'] to a variable but, when i look at the page source now i just do this: <img class="img-responsive" src="img/$userIcon">
– Mikkel Hebel
Mar 28 at 13:54
@executable I have assigned $_SESSION['userIcon'] to a variable but, when i look at the page source now i just do this: <img class="img-responsive" src="img/$userIcon">
– Mikkel Hebel
Mar 28 at 13:54
add a comment
|
4 Answers
4
active
oldest
votes
Here is a simple solution to your problem. You need to remove the php tags and use concatenation.
<?php
if (isset($_SESSION['userId']))
echo '<img class="img-responsive" src="img/'.$_SESSION['userIcon'].'">
<a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else
?>
@executeable Worked, thank you! :D
– Mikkel Hebel
Mar 28 at 14:03
add a comment
|
change
echo '<img class="img-responsive" src="img/<?php print_r($_SESSION['userIcon']); ?>">
to
echo '<img class="img-responsive" src="img/'.$_SESSION['userIcon']).'">';
add a comment
|
You can use something like this:
<?php
if (isset($_SESSION['userId']))
$img = sprintf('<img class="img-responsive" src="img/%s" />', $_SESSION['userIcon']);
echo $img . ' <a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else
// @todo
?>
rsrs
add a comment
|
You have started a PHP code, within a PHP code...
This is the correct img src:
src="img/' . print_r($_SESSION['userIcon']) . '"
I would suggest you store all (temporary) images on your server, and not in a session file :) Have a nice day.
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55399140%2fhow-to-print-image-out-in-html-using-php-echo-and-session-variable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is a simple solution to your problem. You need to remove the php tags and use concatenation.
<?php
if (isset($_SESSION['userId']))
echo '<img class="img-responsive" src="img/'.$_SESSION['userIcon'].'">
<a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else
?>
@executeable Worked, thank you! :D
– Mikkel Hebel
Mar 28 at 14:03
add a comment
|
Here is a simple solution to your problem. You need to remove the php tags and use concatenation.
<?php
if (isset($_SESSION['userId']))
echo '<img class="img-responsive" src="img/'.$_SESSION['userIcon'].'">
<a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else
?>
@executeable Worked, thank you! :D
– Mikkel Hebel
Mar 28 at 14:03
add a comment
|
Here is a simple solution to your problem. You need to remove the php tags and use concatenation.
<?php
if (isset($_SESSION['userId']))
echo '<img class="img-responsive" src="img/'.$_SESSION['userIcon'].'">
<a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else
?>
Here is a simple solution to your problem. You need to remove the php tags and use concatenation.
<?php
if (isset($_SESSION['userId']))
echo '<img class="img-responsive" src="img/'.$_SESSION['userIcon'].'">
<a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else
?>
answered Mar 28 at 13:58
executableexecutable
2,0682 gold badges11 silver badges27 bronze badges
2,0682 gold badges11 silver badges27 bronze badges
@executeable Worked, thank you! :D
– Mikkel Hebel
Mar 28 at 14:03
add a comment
|
@executeable Worked, thank you! :D
– Mikkel Hebel
Mar 28 at 14:03
@executeable Worked, thank you! :D
– Mikkel Hebel
Mar 28 at 14:03
@executeable Worked, thank you! :D
– Mikkel Hebel
Mar 28 at 14:03
add a comment
|
change
echo '<img class="img-responsive" src="img/<?php print_r($_SESSION['userIcon']); ?>">
to
echo '<img class="img-responsive" src="img/'.$_SESSION['userIcon']).'">';
add a comment
|
change
echo '<img class="img-responsive" src="img/<?php print_r($_SESSION['userIcon']); ?>">
to
echo '<img class="img-responsive" src="img/'.$_SESSION['userIcon']).'">';
add a comment
|
change
echo '<img class="img-responsive" src="img/<?php print_r($_SESSION['userIcon']); ?>">
to
echo '<img class="img-responsive" src="img/'.$_SESSION['userIcon']).'">';
change
echo '<img class="img-responsive" src="img/<?php print_r($_SESSION['userIcon']); ?>">
to
echo '<img class="img-responsive" src="img/'.$_SESSION['userIcon']).'">';
answered Mar 28 at 14:04
Danyal SandeeloDanyal Sandeelo
9,0363 gold badges26 silver badges46 bronze badges
9,0363 gold badges26 silver badges46 bronze badges
add a comment
|
add a comment
|
You can use something like this:
<?php
if (isset($_SESSION['userId']))
$img = sprintf('<img class="img-responsive" src="img/%s" />', $_SESSION['userIcon']);
echo $img . ' <a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else
// @todo
?>
rsrs
add a comment
|
You can use something like this:
<?php
if (isset($_SESSION['userId']))
$img = sprintf('<img class="img-responsive" src="img/%s" />', $_SESSION['userIcon']);
echo $img . ' <a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else
// @todo
?>
rsrs
add a comment
|
You can use something like this:
<?php
if (isset($_SESSION['userId']))
$img = sprintf('<img class="img-responsive" src="img/%s" />', $_SESSION['userIcon']);
echo $img . ' <a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else
// @todo
?>
rsrs
You can use something like this:
<?php
if (isset($_SESSION['userId']))
$img = sprintf('<img class="img-responsive" src="img/%s" />', $_SESSION['userIcon']);
echo $img . ' <a href="settings.php">Settings</a>
<form action="lib/logout.php" method="POST">
<button type="submit" name="logout-submit">Logout</button>
</form>';
else
// @todo
?>
rsrs
answered Mar 28 at 14:01
Lucas CampeloLucas Campelo
12 bronze badges
12 bronze badges
add a comment
|
add a comment
|
You have started a PHP code, within a PHP code...
This is the correct img src:
src="img/' . print_r($_SESSION['userIcon']) . '"
I would suggest you store all (temporary) images on your server, and not in a session file :) Have a nice day.
add a comment
|
You have started a PHP code, within a PHP code...
This is the correct img src:
src="img/' . print_r($_SESSION['userIcon']) . '"
I would suggest you store all (temporary) images on your server, and not in a session file :) Have a nice day.
add a comment
|
You have started a PHP code, within a PHP code...
This is the correct img src:
src="img/' . print_r($_SESSION['userIcon']) . '"
I would suggest you store all (temporary) images on your server, and not in a session file :) Have a nice day.
You have started a PHP code, within a PHP code...
This is the correct img src:
src="img/' . print_r($_SESSION['userIcon']) . '"
I would suggest you store all (temporary) images on your server, and not in a session file :) Have a nice day.
answered Mar 28 at 14:01
Hans SchiesslHans Schiessl
92 bronze badges
92 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55399140%2fhow-to-print-image-out-in-html-using-php-echo-and-session-variable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You are in a PHP code section already, so using
<?php
inside of that again makes absolutely no sense. Please go read up on some basics of string concatenation. (We should not have to explain those here, this site is not a replacement for tutorials etc.)– 04FS
Mar 28 at 13:45
3
You could just concat the variable, not sure if this is still the syntax (not done php since v4):
echo '<img class="img-responsive" src="img/' . $_SESSION['userIcon']) . '">';
– Pete
Mar 28 at 13:47
@executable I have assigned $_SESSION['userIcon'] to a variable but, when i look at the page source now i just do this: <img class="img-responsive" src="img/$userIcon">
– Mikkel Hebel
Mar 28 at 13:54