So I'm using PHP to grab my profile picture from my steam profile and i want to display it on the page is there any way to pass the variable containing the picture to html or edit my html code from PHP???
here is my code
<?php
$pic_path = file_get_contents("http://steamcommunity.com/id/LocalSugarDaddy");
preg_match('/<div class="playerAvatarAutoSizerInner"><img src="(.*)" \/><\/div>/i', $pic_path, $pic);
?>
I guess you are trying to use PHP variable containing image URL and want to use in html tag. If so, then you can do below:
<?php
$your_picture_str = "http://www.domainname.com/picture_url.jpg";
?>
<div><img src="<?php echo $your_picture_str; ?>" width="100%" alt="" title="" /></div>
Related
I'm using a php frameworks based on (Yii) , my problem is when I insert an html code to my input text after submit I get a plaintext but i want to get is the html format
example
<img src="https://example.com/ex1/ex1.jpg" border="0"> <img src="https://example.com/ex2/ex2.jpg" border="0">
What I get is text with link to the images
<img src="https://example.com/ex1/ex1.jpg" border="0"> <img src="https://example.com/ex2/ex2.jpg" border="0">
my desired output is images not text with link, I used
html_entity_decode(htmlentities($content)); // not working
html_entity_decode($content); // not working
htmlspecialchars_decode($content); // not working too
nl2br($content); // also not working
the output is in the variable content
<div class="content" id="wall_content_<?= $object->getUniqueId(); ?>">
<?= $content; ?> </div>
THANK YOU
I have a database which contain blob images. I want to display them in a webpage. I'm using the following php code to get the image. But it didn't work properly.
<?php
while($row=mysql_fetch_array($results))
{?>
<tr>
<td><img src="<?php echo $row["image"]?>" height="200" width="250"></td>
</tr>
<?php
}?>
With this code I'm getting a webpage like this.
Where I have to do the correction to my code.
try to convert it to base64:
<img src="data:image/jpeg;base64,<?php echo base64_encode($row['image']); ?>" height="200" width="250">
Note that you should also store the image type in your DB, so you can dynamically change "data:image/jpeg".
I am trying to display image from a blob field of a MySQL table. Looks like I have some sort of error in the following line. As soon as I put "header("Content-type: image/jpeg")" things get messed up and instead of displaying webpage, all source code of the page is displayed.
Please let me know how to correct.
<div class="image" align="left">
<a href="<?php header("Content-type: image/jpeg"); echo $rec['image']; ?>">
<img src="<?php echo $rec['image']; ?>" width="150" border="0"/>
</a>
</div><!-- image -->
You normally don't put the actual image contents in the src= attribute of the image tag. Instead, you point to the URL of an image file.
(There are ways to include the image source directly in the HTML, but it doesn't work consistantly with all browsers, and you still won't have your <a> link working properly.
Instead, the best way to do this is to create a separate PHP file to serve the image.
Your HTML:
<div class="image" align="left">
<img src="myimage.php?key=<?php echo($key) ?>" width="150" border="0"/>
</div><!-- image -->
myimage.php:
<?php
header("Content-type: image/jpeg");
$key = $_GET['key'];
// todo: load image for $key from database
echo $rec['image'];
You're trying to put the image data inline inside the content. The only feasible way to do this is via a Data URI data URI. Something like:
<img src="data:image/jpeg;base64,<?= base64_encode($rec['image']) ?>" width="150" border="0" />
However, what you probably want to do is put it into a separate script. So your HTML would be:
<img src="showimage.php?id=XXX" width="150" border="0" />
And your showimage.php script would be:
<?php
// Get $rec from database based on the $_GET['id']
header('Content-Type: image/jpeg');
echo $rec['image'];
?>
I've done something like that retrieving blob from my database in another way that you may find useful, here is the code example.. see if it suits your needs and if you needed anymore help let me know.
while ($row = mysql_fetch_array($hc_query2)) {
$title = $row['title'];
$text = $row['text'];
$image = $row ['image'];
$output ='<div class="HCInstance"><img src="data:image/jpeg;base64,' . base64_encode($image) . '" alt="High Council" width="100px" height="100px"/>
<div class="HCHeader"><h2>'.$title.'</h2></div><br/><div class="HCDetails"><p>'.$text.'</p></div></div>';
echo $output;
}
i have this code trying to print an image in an html using
session variable from a php.Here is my code:
</head>
<body>
<?php
session_id(1);
session_start();
echo $_SESSION['phname'];
?>
<img src="../uploads/$_SESSION['phname']" alt="photo" width="498" height="720" border="0" />
here:
session_id(1);
session_start();
echo $_SESSION['phname'];
i'm checking if my variable has passed
from the php and its ok.
and here
?>
<img src="../uploads/$_SESSION['phname']" alt="photo" width="498" height="720" border="0" />
i'm using php to print the image from the following source
src="../uploads/$_SESSION['phname']"
when $_SESSION['phname'] is my image's name but i'm not getting the image. Is there something wrong with my code or
is there any other way to print my image?
i try a lot of things and a lot of codes
i found on the net but nothing help me more.
You need to do your session_start before you output anything to the browser as it sends some headers.
And of course when you want to echo something in php, you need php tags and an echo statement...
<?session_start();?>
</head>
<body>
<?php
session_id(1);
echo $_SESSION['phname'];
echo "<img src=\"../uploads/". $_SESSION['phname']."\" alt=\"photo\" width=\"498\" height="720" border="0" />";
?>
I have a PHP echo function inside of a HTML link, but it isn't working. I want to have an image location, defined in img src, be in part of the clickable link of the image. The page will have multiple images doing the same thing, so I am trying to use PHP to automate this.
<a href="http://statuspics.likeoverload.com/<?php echo $image; ?>">
<img src="<?php $image=troll/GrannyTroll.jpg?>" width="100" height="94" />
</a>
Turn
<?php $image=troll/GrannyTroll.jpg?>
into
<?php echo "troll/GrannyTroll.jpg"; ?>
?
Or provide more details on what you are trying to achieve.
Also, you might consider urlencode-ing some of those URL parameters.
Edit:
So you might try setting the variable beforehand:
<?php $image = "troll/GrannyTroll.jpg"; ?>
<img src="<?php echo $picture; ?>" width="100" height="94" />
So now i understand what you are trying to do.
One error is that you didn't enclose $image=troll/GrannyTroll.jpg with quotes like this:
$image = 'troll/GrannyTroll.jpg';
The second error is that you do it in the wrong order, you have to define $image first, before you use it.
That's what I believe you want to do:
<?php
$image = "troll/GrannyTroll.jpg";
?>
<img src="<?php echo $image; ?>" width="100" height="94"/>