Jump to content


Photo

Stop processing periods


  • Please log in to reply
4 replies to this topic

#1 bertieboy_93

bertieboy_93
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 21 August 2006 - 05:24 PM

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 (.).
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.

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 21 August 2006 - 05:32 PM

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?

#3 bertieboy_93

bertieboy_93
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 21 August 2006 - 05:42 PM

<? echo "<img src=\"" . $target_directory$id[color=red][i][b].[/b][/i][/color]jpeg . "\" alt=\"" . $comments . "\"/>" ?>

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

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

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

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 21 August 2006 - 05:51 PM

An error in your coding. Use this
<?php
echo "<img src='{$target_directory}{$id}.jpeg' alt='{$comments}'/>";
?>


#5 bertieboy_93

bertieboy_93
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 21 August 2006 - 06:49 PM

Thanks for replying so quickly and providing me with valuable information.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users