FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Weird IMG problem?

 


Diablosblizz
Call me a noob at coding, but for some reason the image will NOT show. Keep in mind that I am using PHP as well.

Code:
<?php
       error_reporting(0);
       $game = mysql_query("SELECT * FROM `games`");
       while($games = mysql_fetch_array($game)) {
          $image = $games['image'];
         echo "
         <td width='50%'>&nbsp;<div style=\"border:1px dashed #CCCCCC; padding:2px; width:300px;\"><img src='http://diablosb.gigacities.net/$image'></div>
         </td>
         ";
      }
       
       ?>


Please, before you answer, take note of some of the following things:

1. The image is NOT hosted on Frihost (my main hosting is Frihost, and I host my flash games on another host to save bandwidth)
2. The image name is saved in a database, so I just echo it and it comes out.
3. The image URL IS correct.
4. The permissions on the image are 777 (full permission)


So, why isn't the image showing? If possible I will set the images to be hosted on Frihost, but I thought because there is a lot of images I will keep them on a separate host.


What do you guys think? Thanks.
AftershockVibe
What is actually output to the browser? ie What do you actually get when you press View Source?

You're right that there doesn't seem to be anything particularly wrong with what you've got there.
benjad
try using double quotes on the image tag


ref: http://www.evolt.org/these-things-i-know-php-tips
Diablosblizz
AftershockVibe;

This depends on which game the database is looking at. For example, for the game called isoRa the browser outputs:

<img src="http://diablosb.gigacities.net/isora.jpg">

Now, if you take the image URL (http://diablosb.gigacities.net/isora.jpg) and go to it, it shows the image. But, if you go onto my site and look, there is no image.

Benjad;

I have also tried this. Still, nothing.


Also, just to keep you up with the code, here is the current code (I have been updating it):

Code:
<?php
       error_reporting(0);
       $game = mysql_query("SELECT * FROM `games`");
       while($games = mysql_fetch_array($game)) {
          $image = $games['image'];
          $name = $games['name'];
          $desc = $games['desc'];
          $times = $games['tp'];
         echo "
         <td width='50%'>
         <table cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">
         <tr>
         <td rowspan=\"2\" style=\"width:100px;\"><img src=\"http://diablosb.gigacities.net/$image\"></td>
         <td colspan=\"2\" valign=\"top\">$name<BR>$desc</td>
         </tr>
         <tr>
         <td valign=\"bottom\">
         <BR><BR>Times Played: $times
         </td>
         </tr>
         </table>
         </td>
         ";
      }
       
       ?>
AftershockVibe
<pic below>

<pic above>

In theory, I've just embedded the image url you posted into this post. By the looks of it, it doesn't appear here.

It looks like gigacities (whoever they are) is preventing "hotlinking" for the images. If you wish to reference them from external pages you'll need to ask them to disable this or specifically allow it from <whatever>.frihost.com
Diablosblizz
What are you talking about? I can see the image fine. :S
Peterssidan
If you first enter the url of the image you will se it and after that you will be able to se the image here on the forum(after reload).
as AftershockVibe said. They don't allow hotlinking.
AftershockVibe
Diablosblizz wrote:
What are you talking about? I can see the image fine. :S


As you have already been to that image directly, your browser will have cached it. Clear your cache and it won't appear.
Diablosblizz
Okay, the images are now hosted on Frihost. Another question though, if you go and look at my site:

http://twe.frih.net/version/

You see how the Flash Strike is squished? How can I make it so the table displays two in a row, then does a <TR> and does another two?

Example:

Game 1 Game 2
Game 3 Game 4
Game 5 Game 6

Does anybody know how to do this? Current code displaying the games:

Code:
<div align='center'><table width='100%' align='center'><tr><?php
       error_reporting(0);
       $game = mysql_query("SELECT * FROM `games`");
       while($games = mysql_fetch_array($game)) {
          $image = $games['image'];
          $name = $games['name'];
          $desc = $games['desc'];
          $times = $games['tp'];
         echo "
         <td width='50%'>
         <table cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">
         <tr>
         <td rowspan=\"2\" style=\"width:100px;\"><img src=\"http://twe.frih.net/images/icons/$image\"></td>
         <td colspan=\"2\" valign=\"top\">$name<BR>$desc</td>
         </tr>
         <tr>
         <td valign=\"bottom\">
         <BR><BR>Times Played: $times
         </td>
         </tr>
         </table>
         </td>
         ";
      }
       
       ?></tr></table></div>


Many thanks.
mathiaus
A little rough but give this a try...

Code:
<div align='center'>
   <table width='100%' align='center'>
      <?php
      error_reporting(0);
      $game = mysql_query('SELECT * FROM `games`');
      $games = mysql_num_rows($game);
      $games_num_odd = $games&1 ? true : false;
      $count = 1;
      $i = 1;
      while($games = mysql_fetch_array($game)) {
         $image = $games['image'];
         $name = $games['name'];
         $desc = $games['desc'];
         $times = $games['tp'];
         if($count == 1) { echo '<tr>'; }
         ?>
         <td width="50%">
            <table cellspacing="0" cellpadding="2" width="100%">
               <tr>
                  <td rowspan="2" style="width:100px;">
                     <img src="http://twe.frih.net/images/icons/<?php echo $image; ?>">
                  </td>
                  <td colspan="2" valign="top">
                     <?php echo $name; ?>
                     <br /><?php echo $desc; ?>
                  </td>
               </tr>
               <tr>
                  <td valign="bottom">
                     <br /><br />Times Played: <?php echo $times; ?>
                  </td>
               </tr>
            </table>
         </td>
         <?php
         // If we are number 2 or the right side of the table...
         if($count == 2) {
            echo '</tr>';
            $count = 1;
         
         // If we are number 1 or the left side of the table
         } else {
            ++$count;
            if($games_num_odd = true && $i = $games) {
               echo '<td width="50%"></td>
               </tr>';
            }
         }
         ++$i;
      }
      ?>
         
      </tr>
   </table>
</div>
Diablosblizz
The code just spaces each game out.

Game 1
Game 2
Game 3
Game 4
ect.
mathiaus
Hopefully its because I'm daft and used single = signs. Otherwise I don't know
Code:
if($games_num_odd == true && $i == $games) {
Diablosblizz
It worked! Thank you mathiaus!
Diablosblizz
EDIT: Fixed it myself. Razz
phyrexianhulk
use a firefox plugin to show the interpreter output as html. makes things a lot easier
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.