Jump to content

Archived

This topic is now archived and is closed to further replies.

bertieboy_93

Stop processing periods

Recommended Posts

Hi, I'm a newbie to PHP and have very little experience so sorry if this is a stupid question.

As far as I can tell, PHP ignores periods ([color=red][size=18pt][i][b].[/b][/i][/size][/color]).
I have a php script which involves changing a filename and I cannot get the file extension to work because the periods are removed.

So the file test.jpg is processed by the server and delivered to the browser as testjpg
This obviously results in broken links.

I'm sure there is an obvious solution but I have searched php.net and google and these returned nothing.

Share this post


Link to post
Share on other sites
Sounds really strange. PHP is able to have periods in strings. Could you provide us with the code where you try do deal with a string containing periods?

Share this post


Link to post
Share on other sites
[code]<? echo "<img src=\"" . $target_directory$id[color=red][i][b].[/b][/i][/color]jpeg . "\" alt=\"" . $comments . "\"/>" ?>[/code]

The variable $target_directory = "../../images/"
and $id is the id in a mysql database.

In the source code of my browser it reads:
[code]<img src="0jpeg" alt="e3"/>[/code]

So the period between $id and jpeg has been removed, breaking the link.

Share this post


Link to post
Share on other sites
An error in your coding. Use this [code]<?php
echo "<img src='{$target_directory}{$id}.jpeg' alt='{$comments}'/>";
?>[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.