Jump to content

Mutley

Members
  • Posts

    765
  • Joined

  • Last visited

Everything posted by Mutley

  1. I've been trying to modify an existing script, almost alot of it has changed but having a few problems. In which I really need help with. Here is the code: [code]<table align="center" cellpadding="5"> <? $build = false; if(isset($HTTP_GET_VARS["b"]) || isset($HTTP_GET_VARS["build"]))   $build = true; $image = "";  if(isset($HTTP_GET_VARS["image"]))   $image = $HTTP_GET_VARS["image"]; $team = $HTTP_GET_VARS['team']; $game = $HTTP_GET_VARS['game']; $thumbnail_folder = "./gallery/images/".stripslashes($team)."/2006/".stripslashes($game).""; $thumbnail_width = 160; $thumbnail_height = 120; $image_folder = "./gallery/images/".stripslashes($team)."/2006/".stripslashes($game).""; $image_width = 640; $image_height = 480; $source_folder = "./gallery/images/".stripslashes($team)."/2006/".stripslashes($game).""; //The number of thumbs in a row, //followed by the number of rows in a page. $row_size = 3; $page_size = 5; $row = $HTTP_GET_VARS["row"]; if($row == "")   $row = 0; if(is_dir($thumbnail_folder) == false)   mkdir($thumbnail_folder, 0755);   if(is_dir($image_folder) == false)   mkdir($image_folder, 0755);   if(is_dir($source_folder) == false)   mkdir($source_folder, 0755); if($build == true)   {   //Get an array of all the jpg files in the current source directory.   $source_files = glob($source_folder . "/*.JPG");     for($index = 0; $index < count($source_files); $index++)     {     $original_jpg = imagecreatefromjpeg($source_files[$index]);     $original_size = getimagesize($source_files[$index]);     $original_width = $original_size[0]; $original_height = $original_size[1];         $source_file_name = substr($source_files[$index], strrpos($source_files[$index], "/") + 1);         $thumbnail_jpg = imagecreatetruecolor($thumbnail_width, $thumbnail_height);     imagecopyresized($thumbnail_jpg, $original_jpg, 0, 0, 0, 0,                       $thumbnail_width, $thumbnail_height, $original_width, $original_height);     imagejpeg($thumbnail_jpg, $thumbnail_folder . "/" . $source_file_name);     imagedestroy($thumbnail_jpg);         $image_jpg = imagecreatetruecolor($image_width, $image_height);     imagecopyresized($image_jpg, $original_jpg, 0, 0, 0, 0,                       $image_width, $image_height, $original_width, $original_height);     imagejpeg($image_jpg, $image_folder . "/" . $source_file_name);     imagedestroy($image_jpg);                                 imagedestroy($original_jpeg);     }   } ?> <? //Get an array of all the jpg files in the current thumbnail directory. $thumbnail_files = glob($thumbnail_folder . "/*.JPG"); $first_index = $row * $row_size; $last_index = $first_index + $page_size * $row_size; if($last_index > sizeof($thumbnail_files))   $last_index = sizeof($thumbnail_files); for($index = $first_index; $index < $last_index; $index++) { ?> <? if($index == $first_index) { ?> <tr> <? } ?> <? if($index != 0 && $index % $row_size == 0 && $image == "") { ?> </tr><tr> <? } ?> <? $image_file = substr($thumbnail_files[$index], strrpos($thumbnail_files[$index], "/") + 1); $image_url = "gallerytest.php?team=" . $team . "&subject=2006&game=" . $game . "&row=" . $row . "&image=" . $image_file; ?> <? if ($image == "") { ?> <td> <a onclick="window.open(this.href, 'popupwindow', 'width=700,height=600,scrollbars,resizable'); return false;" href="<?= $image_url ?>"> <img width="150" height="120" src="<?= $thumbnail_files[$index] ?>" border="3" style="border-color:aa5500;" /></a></td> <? } ?> <? $next_index = $index + 1; if($next_index >= $last_index)   $next_index = $first_index; $next_image_file = substr($thumbnail_files[$next_index],                           strrpos($thumbnail_files[$next_index], "/") + 1); ?> <!--^ Get Next Image ^--> <? if($image == $image_file) { ?> <td colspan="2"> <a href="gallerytest.php?row=<?= $row ?>&image=<?= $next_image_file ?>"> <img src="<?= $image_folder . "/" . $image_file ?>" border="3" style="border-color:aa5500;" /></a> <br /> <center><a href="javascript:window.close();">Click here to close this Window</a></center> </td> </tr> <!--^ Image full size pop-up ^--> <? $previous_index = $index - 1; if($previous_index < $first_index)   $previous_index = $last_index - 1; $previous_image_file = substr($thumbnail_files[$previous_index],                               strrpos($thumbnail_files[$previous_index], "/") + 1); ?> <!--^ Get Previous Image ^--> <tr> <td> <a href="gallerytest.php?team=<?=$team?>&subject=2006&game=<?=$game?>&row=<?= $row ?>&image=<?= $previous_image_file ?>"><b>Previous Image</b></a> </td> <td align="right"> <a href="gallerytest.php?team=<?=$team?>&subject=2006&game=<?=$game?>&row=<?= $row ?>&image=<?= $next_image_file ?>"><b>Next Image</b></a> </td> <? } ?> <? if($index == count($thumbnail_files) - 1) { ?> </tr> <? } ?> <? } ?> <? if($image == "") { ?> <tr> <td colspan="<?= $row_size ?>"> <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td> <? $previous_row = $row - $page_size; $last_page_size = ceil(sizeof($thumbnail_files) / $row_size) % $page_size; if($last_page_size == 0)   $last_page_size = $page_size; if($previous_row < 0)   $previous_row = ceil(sizeof($thumbnail_files) / $row_size) - $last_page_size; ?> <a href="./teamsgallery3.php?team=<?=$team?>&subject=2006&game=<?=$game?>&row=<?= $previous_row ?>">Previous Page</a> </td> <td align="right"> <? $next_row = $row + $page_size; if($next_row >= ceil(sizeof($thumbnail_files) / $row_size))   $next_row = 0; ?> <a href="./teamsgallery3.php?team=<?=$team?>&subject=2006&game=<?=$game?>&row=<?= $next_row ?>">Next Page</a> </td> </tr> </table> </td> </tr> <? } ?> </table>[/code] The problems are: [s] 1) For the Next/Previous page, they don't go to the next page? It is stuck on row=5.[/s] [s]2) The popup doesn't  work with next/previous image either, like above, the URL is broke.[/s] [b]3) At the moment you need to do a ?b command on the URL to create all the images into thumbnails before the script shows them, I want to remove this feature, so it just automaticly shows the images in the folder, I don't want thumbnails.[/b] I really need help with this, I've got this far and can't stop now, thanks.  :(
  2. Fixed it, damn that was annoying. I included it but forgot to carry the variable. So it couldn't find it. Thanks so much Orio. Means alot.
  3. Even if switched, the $game variable doesn't work, lol. It is confusing the hell out of me, can you try it?
  4. Same problem, $team works but the $game variable doesn't?  ??? It makes no sense.
  5. Nope, won't work, it won't find the "game" variable, if I echo it nothing appears. Heres the whole file: [code]<table align="center" cellpadding="5"> <? $build = false; if(isset($HTTP_GET_VARS["b"]) || isset($HTTP_GET_VARS["build"]))   $build = true; $image = "";  if(isset($HTTP_GET_VARS["image"]))   $image = $HTTP_GET_VARS["image"]; $team = $_GET['team']; $game = $_GET['game']; //$match = $_GET['match']; //echo $match; echo $team; echo $game; $thumbnail_folder = "./gallery/images/".stripslashes($team)."/2006/".stripslashes($game)."/thumbs"; $thumbnail_width = 160; $thumbnail_height = 120; $image_folder = "./gallery/images/".stripslashes($team)."/2006/".stripslashes($game).""; $image_width = 640; $image_height = 480; $source_folder = "./gallery/images/".stripslashes($team)."/2006/".stripslashes($game).""; //The number of thumbs in a row, //followed by the number of rows in a page. $row_size = 3; $page_size = 5; $row = $HTTP_GET_VARS["row"]; if($row == "")   $row = 0; if(is_dir($thumbnail_folder) == false)   mkdir($thumbnail_folder, 0755);   if(is_dir($image_folder) == false)   mkdir($image_folder, 0755);   if(is_dir($source_folder) == false)   mkdir($source_folder, 0755); if($build == true)   {   //Get an array of all the jpg files in the current source directory.   $source_files = glob($source_folder . "/*.JPG");     for($index = 0; $index < count($source_files); $index++)     {     $original_jpg = imagecreatefromjpeg($source_files[$index]);     $original_size = getimagesize($source_files[$index]);     $original_width = $original_size[0]; $original_height = $original_size[1];         $source_file_name = substr($source_files[$index], strrpos($source_files[$index], "/") + 1);         $thumbnail_jpg = imagecreatetruecolor($thumbnail_width, $thumbnail_height);     imagecopyresized($thumbnail_jpg, $original_jpg, 0, 0, 0, 0,                       $thumbnail_width, $thumbnail_height, $original_width, $original_height);     imagejpeg($thumbnail_jpg, $thumbnail_folder . "/" . $source_file_name);     imagedestroy($thumbnail_jpg);         $image_jpg = imagecreatetruecolor($image_width, $image_height);     imagecopyresized($image_jpg, $original_jpg, 0, 0, 0, 0,                       $image_width, $image_height, $original_width, $original_height);     imagejpeg($image_jpg, $image_folder . "/" . $source_file_name);     imagedestroy($image_jpg);                                 imagedestroy($original_jpeg);     }   } ?> <? //Get an array of all the jpg files in the current thumbnail directory. $thumbnail_files = glob($thumbnail_folder . "/*.JPG"); $first_index = $row * $row_size; $last_index = $first_index + $page_size * $row_size; if($last_index > sizeof($thumbnail_files))   $last_index = sizeof($thumbnail_files); for($index = $first_index; $index < $last_index; $index++) { ?> <? if($index == $first_index) { ?> <tr> <? } ?> <? if($index != 0 && $index % $row_size == 0 && $image == "") { ?> </tr><tr> <? } ?> <? $image_file = substr($thumbnail_files[$index], strrpos($thumbnail_files[$index], "/") + 1); $image_url = "gallerytest.php?row=" . $row . "&image=" . $image_file; ?> <? if ($image == "") { ?> <td> <a onclick="window.open(this.href, 'popupwindow', 'width=700,height=600,scrollbars,resizable'); return false;" href="<?= $image_url ?>"> <img src="<?= $thumbnail_files[$index] ?>" border="3" style="border-color:aa5500;" /></a></td> <? } ?> <? $next_index = $index + 1; if($next_index >= $last_index)   $next_index = $first_index; $next_image_file = substr($thumbnail_files[$next_index],                           strrpos($thumbnail_files[$next_index], "/") + 1); ?> <!--^ Get Next Image ^--> <? if($image == $image_file) { ?> <td colspan="2"> <a href="gallerytest.php?row=<?= $row ?>&image=<?= $next_image_file ?>"> <img src="<?= $image_folder . "/" . $image_file ?>" border="3" style="border-color:aa5500;" /></a> <br /> <center><a href="javascript:window.close();">Click here to close this Window</a></center> </td> </tr> <!--^ Image full size pop-up ^--> <? $previous_index = $index - 1; if($previous_index < $first_index)   $previous_index = $last_index - 1; $previous_image_file = substr($thumbnail_files[$previous_index],                               strrpos($thumbnail_files[$previous_index], "/") + 1); ?> <!--^ Get Previous Image ^--> <tr> <td> <a href="gallerytest.php?row=<?= $row ?>&image=<?= $previous_image_file ?>"><b>Previous Image</b></a> </td> <td align="right"> <a href="gallerytest.php?row=<?= $row ?>&image=<?= $next_image_file ?>"><b>Next Image</b></a> </td> <? } ?> <? if($index == count($thumbnail_files) - 1) { ?> </tr> <? } ?> <? } ?> <? if($image == "") { ?> <tr> <td colspan="<?= $row_size ?>"> <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td> <? $previous_row = $row - $page_size; $last_page_size = ceil(sizeof($thumbnail_files) / $row_size) % $page_size; if($last_page_size == 0)   $last_page_size = $page_size; if($previous_row < 0)   $previous_row = ceil(sizeof($thumbnail_files) / $row_size) - $last_page_size; ?> <a href="gallerytest.php?row=<?= $previous_row ?>">Previous Page</a> </td> <td align="right"> <? $next_row = $row + $page_size; if($next_row >= ceil(sizeof($thumbnail_files) / $row_size))   $next_row = 0; ?> <a href="gallerytest.php?row=<?= $next_row ?>">Next Page</a> </td> </tr> </table> </td> </tr> <? } ?> </table>[/code] If I goto ?team=1&game=test It will load the team variable but not game.
  6. Yep, sorted that. Now finally, one more problem. This doesn't make sense: [code]$team = $_GET['team']; $game = $_GET['game']; echo $team; echo $game;[/code] For some reason, if I do ?team=1&game=test ...it doesn't show the game? Why? It just doesn't seem to recognise it, so I can't use it when doing URLs further down: $thumbnail_folder = "./gallery/images/".urlencode($team)."/2006/".urlencode($game)."/thumbs"; It just loads as gallery/images/1/2006//thumbs  ??? Thanks alot Orio.
  7. Thanks alot! I've got that to work now but I have a similar problem here in a FUNCTION: [code]{ echo "<a href=\"http://www.mysite.com/galleryfind.php?team=$team&subject=2006&game={$item}\"\n>{$item}</a> <br />"; }[/code] As you can see, {$item} is some variable and also $team but obviously this doesn't work, I just get a same error as before when I goto that page but I don't know how to get {$item} to work. I tried this: [code]{ ?><a href="http://www.mysite.com/galleryfind.php?team=<?=$team?>&subject=2006&game=<?={$item}?>"><?={$item}?></a> <br /><?php }[/code] But can't seem to get it to work at all. :(
  8. How can I do this then? Any fix of some sort? I need it to include a file with the variables in the URL.
  9. Thanks alot they work. :) Finally, this has been bugging me all week!
  10. When I do this: <?php include("find.php?team=".$team."&subject=".$subject.""); ?> I get this error: Warning: main(find.php?team=1&subject=2006) [function.main]: failed to open stream: No such file or directory in However if I goto the file with my browser address, like www.mysite.com/find.php?team=1&subject=2  ...it works? Anyone know why?
  11. @ Orio Where do I add that code or do I use just that code? How do I use the function to chose which directory I'm wanting the folders to be listed from?
  12. Nope: Fatal error</b>:  Call to undefined function:  scandir() on line 12 That's with removing the "@" with it left on, it doesn't appear any errors, just blank page.
  13. I really need this to be working. If someone can give me a working code and a step by step quote of what each part does, it would mean alot. Thanks.
  14. Gah, I've tried a few different methods but can't get that script to work, it just opens a blank page, no source code. I've tried different directories and all sorts. Yes I'm sure I am on PHP5. Does it work for others?
  15. Just tested it and it works for me. I made 2 .txt files one named "testme.txt" (first line "hello") other was "testme2.txt" (first line "yahoo"). It displayed: hello yahoo :-\
  16. With AOL I'm sure the IP is fixed unless they reconnect their internet connection. It doesn't change on every page they load.
  17. How do you create folders using PHP? Like you would via FTP? Able to give it a name to?
  18. Doesn't seem to work, nothing appears. At the end I put: read_contents("/"); I thought that would show all the folders in the directory the file is in?
  19. Ok, it looks like this now: [code]require_once("connection.php"); for($i=0;$i<$num_rows;$i++) { $team = $_POST['team']; $p = $_POST[p.$i]; $w = $_POST[w.$i]; $d = $_POST[d.$i]; $l = $_POST[l.$i]; $for = $_POST[for.$i]; $against = $_POST[against.$i]; $diff = $_POST[diff.$i]; $pts = $_POST[pts.$i]; mysql_select_db("rufc"); $sql = "UPDATE league SET team='$team', p='$p', w='$w', d='$d', l='$l', for='$for', against='$against', diff='$diff', pts='$pts' WHERE team='$team'"; mysql_query($sql);   echo "The selected information was updated! ";   echo "<a href='league.php'>Click here[/url] to continue";   echo $sql; } [/code] But the problem is still with the league.php which has an error on line 23 due to unexpected "ELSE"?
  20. Any ideas?
  21. Unexpected "else" on line 23: [code]<table align="center" width="60%">   <tr>     <td>Team</td>     <td>P</td>     <td>W</td>     <td>D</td>     <td>L</td>     <td>For</td>     <td>Against</td>     <td>Diff</td>     <td>Pts</td>   </tr> <?php require_once("connection.php"); mysql_select_db("rufc"); $result = mysql_query("SELECT * FROM league ORDER BY pts DESC, diff DESC"); $num_rows=mysql_num_rows($result); for($i=0;$i<$num_rows;$i++) { $res=(mysql_fetch_array($result)); } else { $i=0; $team = $row['team']; ?> <form action="admin_updateleague.php" method="POST">   <tr>     <td> <input type="hidden" name="team" value="<?php echo $row['team']; ?>"> <?=$team?> </td>     <td><input class="form" type="text" size="3" name="<?php echo $i; ?>" value="<?=$row['p']; ?>"></td>     <td><input class="form" type="text" size="3" name="<?php echo $i; ?>" value="<?=$row['w']; ?>"></td>     <td><input class="form" type="text" size="3" name="<?php echo $i; ?>" value="<?=$row['d']; ?>"></td>     <td><input class="form" type="text" size="3" name="<?php echo $i; ?>" value="<?=$row['l']; ?>"></td>     <td><input class="form" type="text" size="3" name="<?php echo $i; ?>" value="<?=$row['for']; ?>"></td>     <td><input class="form" type="text" size="3" name="<?php echo $i; ?>" value="<?=$row['against']; ?>"></td>     <td><input class="form" type="text" size="3" name="<?php echo $i; ?>" value="<?=$row['diff']; ?>"></td>     <td><input class="form" type="text" size="3" name="<?php echo $i; ?>" value="<?=$row['pts']; ?>"></td>   </tr> <?php       } ?> <tr> <td><input class="form" type="submit" value="Update League Table"></td> </tr> <input type="hidden" name="num_rows" value="<?=$num_rows;?>"> </form> <tr> <td> </td> </tr> </table>[/code] Can someone check if that would work anyway? Here is the other file done as you said: [code]require_once("connection.php"); for($i=0;$i<$num_rows;$i++) { $team = $_POST['team']; $p = $_POST[p.$i]; $w = $_POST[w.$i]; $d = $_POST[d.$i]; $l = $_POST[l.$i]; $for = $_POST[for.$i]; $against = $_POST[against.$i]; $diff = $_POST[diff.$i]; $pts = $_POST[pts.$i]; mysql_select_db("rufc"); $sql = "UPDATE league SET team='$team', p='$p', w='$w', d='$d', l='$l', for='$for', against='$against', diff='$diff', pts='$pts' "; mysql_query($sql);   echo "The selected information was updated! ";   echo "<a href='league.php'>Click here[/url] to continue";   echo $sql; } ?> <!--html--> <?php } [/code]
  22. I create a folder using my FTP called "bob". Then on the website, it displays a link to the folder "bob". Like www.mysite.com/bob/ as a hyperlink. So everytime a new folder is created, it is detected and displays it.
  23. Is it possible so when you create a new folder on your server PHP can detect it and display the name of it?
  24. Anyone know whats wrong?  ???
  25. [quote author=makeshift_theory link=topic=108196.msg435005#msg435005 date=1158338907] Well it seems like your only putting one variable in the loop, when you query that db it's going to print out a form for each team however, when you run your check on it on the other page, it doesn't know which form to pull the info from.  So basically what I'm saying is it's like your sending all the variables on the same form and it can't tell which form to get the info from.  you need to put the form tags outside the while loop so that way it's only one form I think this may help. [/quote] How should the PHP be structured?
×
×
  • 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.