PDA

View Full Version : Php error help.


dwguy
08-28-2009, 04:03 PM
Hello Dreamweaverclub.com,
New to the forums here, was hopin you people could help me with a little issue im having with a website. I have a gallery that uses JS and PHP to pull images from a directory. The display works but above the pics i have an error message: "Notice: Undefined variable: count in C:\wamp\www\DBAtest\pics.php on line 65" here is my source code:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pics</title>
<link rel="stylesheet" type="text/css" href="styles/style.css" />
<link rel="stylesheet" type="text/css" href="styles/fancy.css" />

<script type="text/javascript" src="java/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="java/jquery.pngFix.pack.js"></script>
<script type="text/javascript" src="java/jquery.fancybox-1.0.0.js"></script>

<script type="text/javascript">

$(function(){

$(".photo-link").fancybox({ 'zoomSpeedIn': 400, 'zoomSpeedOut': 400, 'overlayShow': true });

});

</script>
<style type="text/css">
<!--
@import url("styles/main.css");
-->
</style>
</head>
<body>
<div id="container">
<div id="header"><img src="images/top banner.jpg" width="967" height="110" alt="Deaf Boyz Audio - Way too loud..." /></div>
<div id="mainContent">
<div id="page-wrap">

<img src="images/header.png" alt="Photo Gallery" /><br />
<?php

/* settings */
$image_dir = 'images/upload/';
$per_column = 6;


/* step one: read directory, make array of files */
if ($handle = opendir($image_dir)) {
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
if(strstr($file,'-thumb'))
{
$files[] = $file;
}
}
}
closedir($handle);
}

/* step two: loop through, format gallery */
if(count($files))
{
foreach($files as $file)
{
$count++;
echo '<a class="photo-link" rel="one-big-group" href="',$image_dir,str_replace('-thumb','',$file),'"><img src="',$image_dir,$file,'" width="100" height="100" /></a>';
if($count % $per_column == 0) { echo '<div class="clear"></div>'; }
}
}
else
{
echo '<p>There are no images in this gallery.</p>';
}

?>

</div>

</div>

<div id="sidebar">
<p class="sidebarLink"><a href="index.htm">home</a></p>
<p class="sidebarLink"><a href="pics.php">pics</a></p>
<p class="sidebarLink"><a href="video.htm">video</a></p>
<p class="sidebarLink"><a href="upload.php">upload</a></p>
<p class="sidebarLink"><a href="about.htm">about</a></p>
<p class="sidebarLink"><a href="feedback.php">feedback</a></p>
</div>
<div id="footer">
<h6 class="copyright">Copyright Deaf Boyz Audio, 2009. All Rights Reserved.</h6>
</div>
</div>
</body>
</html>



line 65 is the line that says "$count++;"
/* step two: loop through, format gallery */
if(count($files))
{
foreach($files as $file)
{
$count++;
echo '<a class="photo-link" rel="one-big-group" href="',$image_dir,str_replace('-thumb','',$file),'"><img src="',$image_dir,$file,'" width="100" height="100" /></a>';
if($count % $per_column == 0) { echo '<div class="clear"></div>'; }
}
}
else
{
echo '<p>There are no images in this gallery.</p>';
}

?>
i dont know if it matters but i only have 2 pics in the gallery so far.

Well thats my issue, hope someone can figure it out... i pulled it off the net so i dont really have a clue about the 'language'. thanks in advance and look forward to meeting you guys.

bee80
08-28-2009, 06:21 PM
i think the script is supposed to echo the clear div after every group of 6 photos:


$per_column = 6;

if($count % $per_column == 0) { echo '<div class="clear"></div>';



but only 0 % 6 = 0, making the code obsolete because it wouldnt have run that far

possibly its meant to be set :

if($count = count($files))

but that still wont run this part : if($count % $per_column == 0) { echo '<div class="clear"></div>';

upload some more pictures and see what happens when u have more than 6

dwguy
08-28-2009, 09:51 PM
ok i uploaded some more pics so i have seven total. still getting the same error. I uploaded it to the web out of curiosity and i dont get any error message when i try to view, just a bunch or image placeholders with the damned "red X"...

edbr
08-31-2009, 02:30 AM
"',$image_dir,str_replace('-thumb','',$file),'"
doesnt look right to me
"$image_dir,str_replace('-thumb','',$file)'" maybe

edbr
08-31-2009, 07:12 AM
and the error is a warning its advising of non coding standards
this can be turned down in the ini file

dwguy
08-31-2009, 04:24 PM
ok changing that code gave me a parse error. non coding standards huh.... does that mean that in some browsers it might be all screwy or what? If it makes a big deal that it would be nice to fix it not just turn the error off. do you think this error is why my pictures dont show up when this page is on the actual web?

dwguy
08-31-2009, 06:31 PM
update.... got the pics to work correctly... funny thing was i didnt change anything. maybe it took my host a while to process everything to make it work right, i dont know. but now uploads can be viewed immediately after they are uploaded.

i just have one issue.... my java is all screwed up, there is supposed to me an "X" in the right corner and a right and left arrow to cycle through the pics when they are big. i can click in that general area and it works, but the image of the arrow and "x"are not there. arrows and such are in the images folder, permissions are right, the buttons function just no images.... any ideas? you can check it out at www.deafboyzaudio.com/pics.php (http://www.deafboyzaudio.com/pics.php)