Image retrieval from mysql database in php not working [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I am getting an image from mysql database and trying to show it. I am using the following code. But its not working .What's the mistake i am making?
while ($row=mysql_fetch_array($result,MYSQL_ASSOC)) {
$photo=$row['photo'];
$name=$row['firstname'].' '.$row['lastname'];
$email=$row['email'];
echo "<tr><td>".'<img src="data:image/jpeg;base64,<?php echo base64_encode( $photo ); ?>" />'.'</td><td>'.$name.'</td><td>'.$email.'</td></tr>';
}

Strip the double quotes after img src because you have already used a single quote before and it is being taken a string so remove double quotes

Ok thanks. I could solve the problem. I just changed the echo line as following
echo "<tr><td>".'<img src="data:image/jpeg;base64,'.base64_encode($photo).'" alt="photo">'."</td><td>".$name."</td><td>".$email."</td></tr>";

Related

Adding a pass with # and \ characters to define('FTP_PASS' '#Aj\Zx5YJG') [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
i want to add a password to this line :
define('FTP_PASS' '#Aj\Zx5YJG')
but wp-confing will not recognize # and \ as characters and for that reason my website goes down.
How can i add those characters as text there?
thanks!
Typo? you're missing a comma between the two parameters and the quotes on the screenshot do not look regular.
http://php.net/manual/en/function.define.php
define('FTP_PASS','#Aj\Zx5YJG');
define('FTP_PASS' '\#Aj\\Zx5YJG')
Escape the characters or use different brackets

Image Source to Include a PHP Input [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am trying to create an image that changes dependent on the genre grabbed from an icecast server, I am pretty sure I have the base code correct I think I've just incorrectly inputted the PHP variable.
<?php
$stats = $core->radioInfo( "http://http://sc.onlyhabbo.net:8124/status-json.xsl" );
?>
<img src=http://www.habbo.com/habbo-imaging/avatarimage?user=<?php
echo $stats['genre'];
?>&action=std&direction=2&head_direction=2&gesture=sml&size=m&img_format=gif/>
is the full code. Have I inputted the PHP variable incorrectly
Where are the quotes in your Html?
<img src="http://www.habbo.com/habbo-imaging/avatarimage?user=<?php
echo $stats['genre'];
?>&action=std&direction=2&head_direction=2&gesture=sml&size=m&img_format=gif"/>
UPDATE EVERYBODY
This is now resolved, I decided to go down the CURL route for this, and at first it didn't work until my host raised our CloudLinux Process Limit. I am unsure what the actual issue with this code was, but the CURL route works fine. Thank you for any answers

Include path with constant and variable [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I'm trying to include a file to current php page but the name of the file depens on the lang.
This line does not work:
include_once PATH.'lang/'.$_SESSION['lang'].'.php';
How can I achieve that?
Your problem should be the "PATH". It must be a string to concatenate with the other strings. For example:
include_once '/sites/all/files/'.'lang/'.$_SESSION['lang'].'.php';
Also be careful with the slashes that make your path to the file.

PHP use a variable in a string [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I hava a problem at my PHP script!
I want to do something like
echo "hello $var";
And the output should be "hello $var". So it should not take the value of $var, but a string "$var".
I want to use this to create a php file with a php script...
Is there any way to solve this?
Thanks in advance!
Use single quotes:
echo 'hello $var';
Or escape the $:
echo "hello \$var";

Confused about PHP syntax error [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I am following video tutorials on the Internet, and this is one of them. However, I am getting a syntax error and can't find where it is.
<?php
function hesapla($ilktarih,$sontarih){
$yil=$son-$ilk;
$ay=$yil*12;
$gun=$ay*30;
return array("$ilktarih","$sontarih","$yil","$ay","$gun");
}
$ilktarih=$_POST["ilk"];
$sontarih=$_POST["ikinci"];
hesapla($ilktarih,$sontarih);
list ("$ilktarih","$sontarih",$yil,$ay,$gun)=hesapla($ilktarih,$sontarih);
?>
Remove double quotes from list variables like this :
<?php
function hesapla($ilktarih,$sontarih){
$yil=$son-$ilk;
$ay=$yil*12;
$gun=$ay*30;
return array("$ilktarih","$sontarih","$yil","$ay","$gun");
}
$ilktarih=$_POST["ilk"];
$sontarih=$_POST["ikinci"];
hesapla($ilktarih,$sontarih);
list ($ilktarih,$sontarih,$yil,$ay,$gun)=hesapla($ilktarih,$sontarih);
?>

Categories