Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with cross browser issue & PHP

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help!
View previous topic :: View next topic  
Author Message
photobod



Joined: Thu Apr 21, 2005 8:18 pm
Posts: 94
Location: London

PostPosted: Thu Jul 28, 2005 10:04 am    Post subject: Problem with cross browser issue & PHP Reply with quote

I'm nearing the end of developing a new website which uses PHP/MySQL to handle user sessions and generate image galleries on the fly for voting purposes.

While everything works fine in Moz/FF/Konq, there are a couple of issues with IE (no kidding!) and Opera which I'm having problems sorting out.
First, the site is frame-based and although Moz/FF/Konq/IE don't show the frame borders 'cause I've made them zero, Opera does show thin grey outlines on all frames. IE shows some white lines, but not on all frames.

Second, and much more important, although all browsers show the gallery contents when the user is not logged in, as soon as the user logs in, IE/Opera no longer generate the thumbnails.

To ensure that only logged in users can vote, the thumbnail script detects whether the user is logged in and generates the links only if they are. The links include GET data, passed to the voting script

I think I've tied the problem down to a specific line of code, but I can't actually see anything wrong with it. Remember, it works fine in proper browsers!

NOTES on the code snippet:
1) function clickable returns true if the user is logged in.
2) $gallery is the URL of the gallery folder in use and is set from GET data passed to the script.

<?
if (clickable())
{
echo "<b>Click any image to vote.<br>" . "You may vote only once for any individual entrant.<b>";
}
else
{
echo "<b>You are welcome to browse, but you must be registered and signed in to vote.<b>";
}
// build page as table of four columns, each 125px wide
$pix = array();
$dh = opendir($gallery);
while (false !== ($filename = readdir($dh)))
{
$pix[] = $filename;
}
$column = 0;
echo "<table align=\"center\">";
foreach ($pix as $pic)
{
if (($pic==".") || ($pic==".."))
continue;
// Set up the full path to the picture
$picUrl=$gallery . "/" . $pic;
// Get the width and height of the image
$size = getimagesize("$picUrl");
if ($size[0] > $size[1])
$scale = $size[0] / 125;
else
$scale = $size[1] / 125;
// Now set the size of the image
$width = $size[0] / $scale;
$height = $size[1] / $scale;
// Start a new row if necessary
if ($column == 0)
echo "<TR>";
// Create a new item
echo "<td align=\"center\" valign=\"middle\">";
// Add a hyperlink if the user is logged in
if (clickable())
{
$linkto = "vote.php?votefor=" . $pic . "&page=" . $page . "&picUrl=" . $picUrl;

// Up to this point, everything works in IE/Opera.
// If the variable $linkto is simply echoed to the page, they render
// a table of link addresses with appended GET data.

echo "<a href=\" $linkto \"";
}
// Add the image
echo "<img width=$width height=$height src=\"" . $picUrl . "\" >";
// End the hyperlink if the user is logged in
if (clickable())
echo "</a>";
// Complete the item
echo "</TD> \n";
$column++;
if ($column == 4)
{
echo "</TR> \n";
$column = 0;
}
}
?>
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help! All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast