Can not view images with spaces in its name [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 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 cant view images with spaces in its name ex: Google Twitter.JPG is not loading and its name is changed to Google%20Twitter.JPG after the PHP echo method .
<image width=150px height = 100px src="upload/profiles/<?php echo trim($image); ?> >

You have an error in your markup.
Change <image width=150px...
to
<img width=150px...

This is a requirement in W3 Standards
From http://www.w3schools.com/tags/ref_urlencode.asp :
URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign or with %20.
You should rename your images, and replace the spaces with either dashes - or underscores _
As pointed out in comments, you are missing a quote, and have some errors in your line. image should be img and your height and width attributes should be in quotes with no spaces.
<img width="150px" height="100px" src="upload/profiles/<?php echo trim($image);?>" />

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 src (url) not working [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 5 years ago.
Improve this question
I have image tag like below
<img src="www.example.com/imgs/file.jpg" />
but this is not working and when i look at page src i see
<img src="site1/std/www.example.com/imgs/file.jpg" />
i tried to escape the two dirs by adding
<img src="../../www.example.com/imgs/file.jpg" />
but this just give me :
<img src="../../site1/std/www.example.com/imgs/file.jpg" />
what's wrong with my code???
If the image is located on the server where your script is, then you can use
<img src="imgs/file.jpg" />
If its on an external site, then you need to use the full link, like so
<img src="http://www.example.com/imgs/file.jpg" />

Calling a PHP variable through button onclick [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 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
The goal is to call the variable $url when the button is clicked. With this current bit of code, when the button is clicked nothing happens and the error says unexpected token.
<?php
$url = "edit_beginningcakephp.php?title=$title&author=$author&isbn=$isbn
&year=$year&pages=$pages&price=$price";
>?
<input type="button" value="Edit Book" onclick="window.location.href='<?= $url ?>'">
I suppose you're not correctly encoding the content of the variables (known as XSS)
You need to urlencode the content of your variables. Also, & needs to be entered as an HTML entity &.
Try:
$url = 'edit_beginningcakephp.php?title='.urlencode($title).'&author='.urlencode($author).'&isbn='.urlencode($isbn).'&year='.urlencode($year).'&pages='.urlencode($pages).'&price='.urlencode($price);
PS: >?should be ?> and make sure the URL doesn't contain any newlines.
" >? "
That looks like it might be a problem, definitely throws a syntax error on my local :)
While MrTux's answer is very good and his advice should surely be followed, the actual problem with your code is the return in the URL. URLS can't contain returns!
Solution: delete the return. And the spaces. And follow MrTux's advice.

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

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>";

Add <sup> in PHP not working [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
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 editing a wordpress page and I am required to put square meter simbol m2 into a textbox. However I've been at it for an hour or more and I cannot get it to work. Php errors range from syntax error to T_ENCLOSED_STRING.
The Min Area (m2) is the text I want to edit.
The code:
<input type="text" class="field" name="area-min" id="area-min"
placeholder="<?php _e('Min Area (in m2)','realspace'); ?>"
value="<?php echo $_GET['area-min']; ?>" />
You can't put HTML in a placeholder. What you want is the special character ² which is ²
e.g.
_e('Min Area (in M²)','realspace')
You can't put HTML tag in inputs. But, you can use superscript characters:
<input type="text" class="field" name="area-min" id="area-min"
placeholder="Min Area (in m²)"
value="<?php echo $_GET['area-min']; ?>" />
Here, I'm using the ² character.
See also: Superscript in input field of text type

Categories