Nov 21, 2009
Pages: 1, 2, 3

Php And Showing Pics

free web hosting

Read Latest Entries..: (Post #24) by wutske on Dec 18 2008, 10:49 AM.
QUOTE (khalilov @ Dec 16 2008, 05:16 PM) Iam trying to make my site compatable with both firefox and IE, liek i said that code isn't mine i'll try to fix it.Don't use hacks for FF and IE compatibitly, it's a nasty habbit. It's a much better practice if you aquire this by using different codes.IE hacks should only be use if there's no other way (ie. the screwed up IE6 engine is causing you headaches)....
read more.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Php And Showing Pics

khalilov
I made a small script which creates a 10x10 picture out of small pictures
CODE
<html>
<body>
<?php
for($j=0;$j<10;$j++)
   {{for($i=0;$i<10;$i++)
   echo "<img src=C:\wamp\www\Game\pic\grass.jpg>";
   }
   echo "<br>";
   }
?>

</body>
</html>

grass.jpg is a simple pic, anyways when i run it using wamp it shows 10x10 pics of nothing, as in the pics aren't loading. When i right click them and enter properties it says they are not available. I enter page source and find
CODE
<img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><br><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><br><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><br><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><br><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><br><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><br><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><br><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><br><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><br><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><img src=C:\wamp\www\Game\pic\grass.jpg><br>
</body>

Basicly its the code that shows the image 100 times, i copy and paste the code and save it as .html , the big pic shows normally. I save the php file as .html and when i open it i get
CODE
"; } echo "
"; } ?>


I thought it had something to do with the loops so i modified it to simply
CODE
<html>
<body>
<?php

   echo "<img src=C:\wamp\www\Game\pic\grass.jpg>";
  
?>

</body>
</html>

Same result, a picture with not available source and grass.jpg is not viewing, how do i make them show? I tried in both firefox and IE.
How do i make pics work in php?

Edit: i noticed i got alot of mycents on this post i think, iam guessing this is from the 100 img viewing codes i posted, if it is considered spam or abuse, plz replace them with quotes =)

 

 

 


Comment/Reply (w/o sign-up)

wutske
You're not using the img tag correctly.
It should be:
CODE
<img src="C:\wamp\www\Game\pic\grass.jpg" />


instead echo "<img src=C:\wamp\www\Game\pic\grass.jpg>" prints
CODE
<img src=C:\wamp\www\Game\pic\grass.jpg>

(without the quotes around the path).

Change your echo command into this and it should work:
CODE
echo '<img src="C:\wamp\www\Game\pic\grass.jpg" />'



btw. avoid using absolute paths, makes it incredibly hard to migrate your website.

Comment/Reply (w/o sign-up)

khalilov
Still doesn't work :/, and what do you mean making it hard to migrate my website?

Edit: I saved it as .html and noticed that it works when i open it directly, but when i open it from localhost (http://localhost/game/x.html) it doesn't work.
QUOTE
Server Configuration

Apache Version :
2.2.8
PHP Version :
5.2.6

Thats the wamp version iam using.

Comment/Reply (w/o sign-up)

turbopowerdmaxsteel
Try adding file:// before the C:\wamp part.

At present your website is located in your localhost. Migrating it implies that you are moving it to a real host so that it can be accessed on, say, yourdomain.com. Suppose your index file is localhost/index.php and the pictures are located in the pic directory. Its best to use relative URLs such as <img src='/pic/grass.jpg' />. Now when you move your website to yourdomain.com, all you need to do is copy the files (PHP & Images) to your hosted account. In the current scenario, you will need to change the src attribute to <img src='http://yourdomain.com/pic/grass.jpg' /> when you move to yourdomain.com, <img src='http://khalilov.astahost.com/pic/grass.jpg' /> if you are moving to khalilov.astahost.com, and so on.

Note: Remember that ./ refers to the current directory, .. the parent and / the root directory.

Comment/Reply (w/o sign-up)

khalilov
It works thanks alot m8 biggrin.gif
I was just testing it thats why i put the direct link to the page =)
Btw when i open it in firefox there is a distance between the image. Iam assuming its default in firefox, but i want the pics to appear right next to each other like in IE, whats the CSS code to do so =), i tried
CODE
<table border=0 cellspacing=0>
<?php

  for($j=0;$j<10;$j++)
   {echo "<tr>"; for($i=0;$i<10;$i++)
   {?>
   <td><img src="file:\\C:\wamp\www\Game\pic\grass.jpg"></td>  
  <?php }
  echo "</tr>";
  }

?>
</table>

The distance between the pics got smaller but it is still easily noticable.

Edit: its working in firefox but not in IE O.o,output page source is the same

Also can you tell me how to do the file link with :/pic/grass.jpg , file://pic/grass.jpg doesn't seem to work

 

 

 


Comment/Reply (w/o sign-up)

Quatrux
I don't understand why are you creating links from windows environment for file:// ??? if you're using PHP why not use the normal http address? for example:

http*://localhost/Game/pic/grass.jpg ???

you can get the full/absolute path in different ways, one way is to use $_SERVER; super global, just look the array value you need by doing:

CODE
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
exit;


and you'll see what you can get and what you can use with it.. If you ask me, never use the file:// path, if possible avoid using absolute path, the best method is just writing:

images/image.jpg and that in that html file the browser could find it, one way is to use ../ parent dir or ./ current dir or ../../ two parent directories:

../images/image.jpg it will take the image from a parent directory in that location if it's accessible wink.gif

Comment/Reply (w/o sign-up)

khalilov
In the begining i wrote just parent and file and absolute path but neither showed the image wink.gif. The image was blocked for some reason. Read my first post and you'll understand =)

Comment/Reply (w/o sign-up)

turbopowerdmaxsteel
You have always been using file path. Initially you were missing the quotations " around the value of the src attribute. I presume your page is located at http://localhost/Game/index.php. Its best that you use the img tag as <img src="/Game/pic/grass.jpg"> (relative to the root) or <img src="pic/grass.jpg"> (relative to the current page).

Comment/Reply (w/o sign-up)

khalilov
But how come they don't appear in IE :/

Comment/Reply (w/o sign-up)

Quatrux
you're doing something wrong or maybe you have some super cool anti spyware which does not let IE to view localhost content? or something like that, those kind of things works on all the browsers I know. wink.gif

Comment/Reply (w/o sign-up)

Latest Entries

wutske
QUOTE (khalilov @ Dec 16 2008, 05:16 PM) *
Iam trying to make my site compatable with both firefox and IE, liek i said that code isn't mine i'll try to fix it.


Don't use hacks for FF and IE compatibitly, it's a nasty habbit. It's a much better practice if you aquire this by using different codes.
IE hacks should only be use if there's no other way (ie. the screwed up IE6 engine is causing you headaches).

Comment/Reply (w/o sign-up)

yordan
QUOTE (Quatrux @ Dec 15 2008, 07:43 PM) *
I don't know, but when I remove this line: </style><!--[if lte IE 6]>

I already had this problem in one of my HTML pages, I removed the line and it worked fine, even with Internet Explorer.
QUOTE
Iam trying to make my site compatable with both firefox and IE, liek i said that code isn't mine i'll try to fix it.

I agree, your site should be visible by everyone, including the poor guys who bought a ready-for-use computer with IE6 installed. However, the instruction "[if lte IE 6]>" could happen to be not absolutely necessary, so simply try your thing with IE6 and if it works, let's simply be happy and forget about everything else. laugh.gif

Comment/Reply (w/o sign-up)

khalilov
Iam trying to make my site compatable with both firefox and IE, liek i said that code isn't mine i'll try to fix it.

Comment/Reply (w/o sign-up)

Quatrux
I don't know, but when I remove this line: </style><!--[if lte IE 6]>

Everything starts to work, I never used any of those hacks for IE, because I hate IE in some way and everything or most of the stuff can be done without that nonsense.. I use IE7 and when I remove that line it works, so something is bad with your syntax for those kind of hacks with IE or whatever you can call them.

Comment/Reply (w/o sign-up)

khalilov
Iam trying to recreate it since iam gona use that alot on my site.
CODE
<link rel="stylesheet" type="text/css" href="map.css" />
[tab][/tab][tab][/tab]<style type="text/css">
/*<![CDATA[*/
[tab][/tab][tab][/tab]/* =======
[tab][/tab][tab][/tab]Template CSS
[tab][/tab][tab][/tab]============*/

[tab][/tab][tab][/tab]* html { margin:0; padding:0;}
[tab][/tab][tab][/tab]html, body { height: 100%; }
[tab][/tab][tab][/tab]#wrapper { min-height: 100%; }   /* div you want to stretch */
[tab][/tab][tab][/tab]body { margin:0 auto; text-align:center; background-color: #eeddbb; }
[tab][/tab][tab][/tab]p { margin: 1em; padding:1em; text-align:left }
[tab][/tab][tab][/tab]#wrapper { margin: 0 auto; width:1000px; background-color: #ffeecc; border: 1px solid #666666; }
[tab][/tab][tab][/tab]#header { margin: 1em 0; text-align:center; border-bottom: 1px solid #666666; }
[tab][/tab][tab][/tab]#header h1 { margin: 1em 0; }
[tab][/tab][tab][/tab]#footer { margin: 1em auto; padding: 1em; text-align:center; border-top: 1px solid #666666; }
[tab][/tab][tab][/tab]#footer a { margin: 1em auto; padding: .15em; }
[tab][/tab][tab][/tab]/* =======
[tab][/tab][tab][/tab]Page specific CSS Below this line
[tab][/tab][tab][/tab]============*/
[tab][/tab][tab][/tab] a:link {  color: white; text-decoration: none; }
   a:visited {  color: green; text-decoration: none; }
   a:hover { color: orange; }

[tab][/tab][tab][/tab]h1,h2 {
[tab][/tab][tab][/tab]text-align:center;
[tab][/tab][tab][/tab]}

[tab][/tab][tab][/tab]h3 {
[tab][/tab][tab][/tab]text-decoration: underline;
[tab][/tab][tab][/tab]text-align: left;
[tab][/tab][tab][/tab]margin-left:5em;
[tab][/tab][tab][/tab]}

[tab][/tab][tab][/tab]h4 {
[tab][/tab][tab][/tab]margin: .5em 5em;
[tab][/tab][tab][/tab]text-align: left;
[tab][/tab][tab][/tab]}

[tab][/tab][tab][/tab]p {
[tab][/tab][tab][/tab]margin: 4px 5em;   /* ==> left and right margins are critical. see notes on page */
[tab][/tab][tab][/tab]padding: 4px 10px;
[tab][/tab][tab][/tab]text-align:justify;


[tab][/tab][tab][/tab]}

[tab][/tab][tab][/tab]/*
[tab][/tab][tab][/tab]=================================
[tab][/tab][tab][/tab]start of Tooltip css code here
[tab][/tab][tab][/tab]================================= */

[tab][/tab][tab][/tab]a.info{
[tab][/tab]  
[tab][/tab][tab][/tab]text-decoration:none;
[tab][/tab][tab][/tab]font-style:italic;
[tab][/tab][tab][/tab]}

[tab][/tab][tab][/tab]a.info:hover {
[tab][/tab][tab][/tab]z-index:125;
[tab][/tab][tab][/tab]background-color:#ffff66;

[tab][/tab][tab][/tab]}

[tab][/tab][tab][/tab]a.info span{
[tab][/tab][tab][/tab]display: none;  /* hide the span text using this css */
[tab][/tab][tab][/tab]}

[tab][/tab][tab][/tab]a.info:hover span{ /*the span will display just on :hover state*/
[tab][/tab][tab][/tab]display:block;
[tab][/tab][tab][/tab]position:absolute;
[tab][/tab][tab][/tab]top: 0px;
[tab][/tab][tab][/tab]left: -100px;
[tab][/tab][tab][/tab]width:100px;
  
[tab][/tab][tab][/tab]border:1px solid orange; /* border colour */
[tab][/tab][tab][/tab]background-color:yellow; /* background colour here */
[tab][/tab][tab][/tab]color:#000000;[tab][/tab][tab][/tab] /* text colour */
[tab][/tab]  
[tab][/tab][tab][/tab]
[tab][/tab][tab][/tab]text-align: center;
[tab][/tab][tab][/tab]font-size: 15px;
[tab][/tab][tab][/tab]
[tab][/tab][tab][/tab]z-index:30;
[tab][/tab][tab][/tab]}

[tab][/tab][tab][/tab].images {
[tab][/tab][tab][/tab]vertical-align:bottom;
[tab][/tab][tab][/tab]}


[tab][/tab][tab][/tab]/*]]>*/
[tab][/tab][tab][/tab]</style><!--[if lte IE 6]>
<style type="text/css">
#wrapper {
height: 100%;
}
</style>

<p class="map">
<?php
$x=$_GET['x'];$y=$_GET['y'];
$x*=74;
$y*=57;
echo "<a class=info><img class='images' alt='' style='position:relative;top:".$y."px;
left:".$x."px;'src='pic/mark.jpg' ><span>mark</span></a>";
?>
<?php /* <table  class=boldtable1 cellspacing=0>
<link rel="stylesheet" type="text/css" href="map.css" />
<?php
$x=$_GET['x'];$y=$_GET['y'];
  for($j=0;$j<10;$j++)
   {echo "<tr>"; for($i=0;$i<10;$i++)
   {if(($i!=$x)||($j!=$y)){?>
   <td>
[tab][/tab]<?php echo "<a href=map.php?x=".$i."&y=".$j.">"; ?>
  
[tab][/tab]<img src="pic/grass.jpg"></a></td>  
  <?php }
   else { ?>
   <td><img src="pic/mark.jpg"></td>
  <?php }}
  echo "</tr>";
  }
</table>  */
?>
</p>


The CSS file is still the same, the pic that will reveal mark when hovered over does not appear in IE, can you do your magic and tell me what you did cuz i keep modifiing and recreating the code, so i don't wanna keep asking the same subject over and over :/

Note: some of the code (CSS part) i got from the internet, do i need to quote it too? do i use quote and code tags at the same time?

Edit: whats with the tabs in the code O.o

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Pages: 1, 2, 3
Similar Topics

Keywords : Php Showing Pics


    Looking for Php, Showing, Pics

See Also,

*SIMILAR VIDEOS*
Searching Video's for Php, Showing, Pics
advertisement



Php And Showing Pics

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com