Jump to content

Recommended Posts

brokenimages.gif

 

Looking in the image above, you can see two rows where the images(smileys) are showing, unbroken.

In the row just above those two, and the row just below, you can see image placeholders, where the images have broken.

 

What I have found causing this is this;

The database table for the mail has a preview field, which is the one the broken images are showing in. 

That preview field, limits to 40 characters, which is fine. Except, if an image is inserted into that field at the 40 character cutoff limit, than the image is returned broken, as the image code gets cut off.  However if the image code manages to fit, before the 40 character limit, than the image comes back fine.

I've tried a few different things, and although I have been learning php at an amazing speed since buying my game and rebuilding the code, there are still some areas I am not familiar with.

 

I'm thinking there should be a way to either limit the size of the <td> or the <tr> so that it will show shorter than the database table's field, thereby hiding the broken image out of view, or maybe there is a way to write the code that displays that field on the player side, so that it will not display the images at all.

Btw, most of the time, I only see this problem when testing the game in IE.  I do see it in FF sometimes, but not nearly as often.

 

Well I'm not sure if I'm even close to hitting the nail on the head with my ideas about how to solve the problem.  I am definitely open to any ideas or input.

The reasons I'm asking for help on this one, instead of toughing it out, like I normally would, is that for one, it looks unprofessional to my players, but also because it is causing reports on my tracking logs of these broken images.  As they are pretty much the only thing causing my tracking reports to show errors, it's pretty well driving me nuts.  lol

 

I will check back regularly, so if you have any questions, or would like more screenshots, or whatever, just let me know please.  You can of course sign up to my game, if you want to help me test the results, but as I'm not sure about the rules here, I won't post my link.  If you want the link, you can email me at az_critter1@yahoo.com.

 

Btw, I know this is probably something that should be fairly simple, but my brain is probably code swamped as I've been working on the codes almost every day from early morning to late night.  lol  :-[

Thanks a lot in advance for your time and help,

                                                            Az_Critter  :)

Link to comment
https://forums.phpfreaks.com/topic/186899-help-with-broken-images-in-php-please/
Share on other sites

One more thing I forgot to mention.

I don't want to completely remove the images from the mail, as when the players click on the preview link, it takes them to the view of the entire message, where the images all show perfectly.

 

Thanks again,

              Az_Critter  :)

ok... what you'd WANT to do.. is count anything not inside of the html tags.. so when you're getting the previews.. do this:

 

$preview = substr(strip_tags($content),0,40);

 

actually this will remove the image tags.. you'd want to make your own function to avoid them then.. or use regex but back tracking in the Regular Expressions engine is alot laggier than just moving forward.. so heres what I've put together for you.

<?php
function getValidChars($data,$enum) {
	$inTag = false;
	$returning = '';
	$num = 0;
	for ($i = 0; $i < strlen($data); $i++) {
		$current = substr($data,$i,1);
		if (!$inTag) {
			if ($current == "<") $inTag = true;
			else $num++;
		} else {
			if ($current == ">") $inTag = false;
		}
		$returning .= $current;
		if ($num >= $enum) return $returning;
	}
}
$i = getValidChars("a b c <b>d</b> e f g h i j k l m n o p q r s t u v w x y z",25);
echo  "<div>{$i}</div><div>".strlen($i)."</div>";
?>

 

 

but you see.. the above code doesn't take into consideration whether or not there is any open tags which need to be closed.. so bear that in mind.. but its tested and works

I did what you first suggested, and as you stated it did remove the tags.  Then I was going to try your second suggestion, but a big "Wow" happened.  lol

 

I went into my function file to add in the function you suggested, but stumbled onto some of my smiley codes in there.  Some of which I had changed after I bought the game, but hadn't changed in there, as I never reallized they existed in that file.  lol

 

So now I'm wondering if that is what is causing the whole issue.  Going to investigate it further, by changing those codes to the new ones.  If that still doesn't solve it, then I'll go ahead and try your suggested function.

 

Thanks a lot for your help, and I'll be back to let you know what happens.  :)

I fixed the smiley codes, but of course that didn't change anything, as it is the character limit cutting off the codes that is causing it, as I first stated.

 

So I tried the suggested function, but it caused an error on my pages which showed "valid characters" where it shouldn't have been.

Of course I'm still pretty new at this, and while I've learned a lot, I still have much more to learn.  So it's quite possible that I'm just not doing something correctly.

 

I wonder though, as you stated that function doesn't take open tags into consideration, if it would fix my problem anyway, as it is the open tags (open after being cut by the field) which are causing the problem to begin with?

 

I think I'll do some more studying up on functions while I'm waiting for a reply.  :)

What a "Duh" moment...    :-[

Sorry about that.  Just having my coffee still... 

 

Realized of course that I needed to set the echo in the correct file.  lol

Then  that I needed to switch out the "valid characters in the variable string with correct variable to match my codes. 

Haha, don't even know if I'm using the correct terms, but I'm sure you know what I'm talking about.  ::)

Gotta say that in all my time of diving into the codes, this is my #1  "Duh" moment ever.  lmao

 

Anyway, I did all of that, with your suggested function, and it appears to be working perfectly!  Going to continue testing it, but from all quick appearances, it seems I couldn't have asked for a better solution.

 

Thank you very much,

                            Az_Critter  :D

The broken images showing is all solved.  The only problem I'm seeing now is that the preview field doesn't display a preview, when the open tag ends the data.

 

Any ideas on how to fix that one?

 

Thanks again,

                Az_Critter  :)

feel free to add me to MSN or AIM to ask me questions directly based on this topic.. the open tags are going to stay open but what you CAN do is remove all possible tags besides the img tag.. from the preview not the whole thing.. so like..

 

$preview = theFunctionIshowed($content,40);

$preview = str_replace(array("<b>',"</b>","<i>","</i>"),'',$preview);

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.