nsr500rossi Posted January 16, 2008 Share Posted January 16, 2008 Hi, Can anyone tell me why my filename is being chopped in half when i run my editxml.php command The problem line in the code is: name=ECO_001.jpg&album=_2006' it should read name=ECO_001.jpg&album=Ecofair_2006' This is the code that is created after running the editxml.php command. <?xml version="1.0" encoding="utf-8"?> <gallery> <album title="Ecofair 2006" description="Photographs from the 2006 Ecofair in Burgess Hill" lgPath="http://www.michaelshuttleworth.com/Event/albums/Ecofair_2006/lg/" tnPath="http://www.michaelshuttleworth.com/Event/albums/Ecofair_2006/tn/"> <img src="ECO_001.jpg" title="Please click on Photograph to purchase" caption="ECO_001.jpg" link="javascript:NewWindow=window.open('/Payment_page.php?name=ECO_001.jpg&album=_2006','myWindow','width=300,height=700,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');NewWindow.focus(); void(0);" /> </album> </gallery> Here is the editxml.php code <html> <head> <title>PHP Test</title> </head> <body> <?php $file = "images.xml"; $descriptor = fopen ($file, "r"); $contents = fread($descriptor , filesize($file)); $album = ''; $pos1 = strpos($contents, 'javascript:NewWindow'); if ($pos1 == false) { $pieces = explode('link=""', $contents); $op = ""; for ($i = 0; $i < count($pieces); $i++) { $tnpos = strpos($pieces[$i], 'tnPath="'); if ($tnpos !== false) { $titpos = strpos($pieces[$i], 'Event/albums/', $tnpos); $titpos += 20; $titend = strpos($pieces[$i], '/', $titpos) - $titpos; $album = substr($pieces[$i], $titpos, $titend); //echo $album; } $halves = explode('<img src="', $pieces[$i]); $fileid = substr($halves[1], 0, 7); if (count($halves) > 1) { $halves[0] .= '<img src="'; $pos1 = strpos($halves[1], 'unavailable'); if ($pos1 == false) { $halves[1] .= "link=\"javascript:NewWindow=window.open('/Payment_page.php?name=" . $fileid . ".jpg&album=" . $album . "','myWindow','width=300,height=700,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');NewWindow.focus(); void(0);\""; } else { $halves[1] .= 'link=""'; } } $op .= $halves[0] . $halves[1]; } fclose($descriptor); unlink($file); //$descriptor = fopen ('images.txt', "w"); $descriptor = fopen ($file, "w"); fwrite($descriptor,$op); echo 'done! '; echo count($pieces); echo ' pieces processed'; fclose($descriptor); } else { echo 'This file has been processed already'; } ?> </body> </html> A friend of mine wrote the code for me and it works fine on my old website http://www.michaelshuttleworthphotography.co.uk/Event_Photos_Part_1.html As you can see when you click on the image it gets the image info and thumbnail and opens it in a new window. On my new site it is tripping up on getting the thumbnail. Thanks in advance Mike Quote Link to comment https://forums.phpfreaks.com/topic/86352-newbie-php-code-help/ Share on other sites More sharing options...
revraz Posted January 16, 2008 Share Posted January 16, 2008 echo $album and see what it contains. Quote Link to comment https://forums.phpfreaks.com/topic/86352-newbie-php-code-help/#findComment-441228 Share on other sites More sharing options...
nsr500rossi Posted January 16, 2008 Author Share Posted January 16, 2008 Hi Revraz Ok so i am he original newbie. How do i echo the album? Mike Quote Link to comment https://forums.phpfreaks.com/topic/86352-newbie-php-code-help/#findComment-441238 Share on other sites More sharing options...
Ken2k7 Posted January 16, 2008 Share Posted January 16, 2008 Please use tags. People don't give posts like these much consideration if you don't use them when posting codes. Try replacing you xml file with this: <?xml version="1.0" encoding="utf-8"?> <gallery> <album title="Ecofair 2006" description="Photographs from the 2006 Ecofair in Burgess Hill" lgPath="http://www.michaelshuttleworth.com/Event/albums/Ecofair_2006/lg/" tnPath="http://www.michaelshuttleworth.com/Event/albums/Ecofair_2006/tn/"> <img src="ECO_001.jpg" title="Please click on Photograph to purchase" caption="ECO_001.jpg" link="javascript:NewWindow=window.open('/Payment_page.php?name=ECO_001.jpg&album=Ecofair_2006','myWindow','width=300,height=700,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');NewWindow.focus(); void(0);" /> </album> </gallery> Quote Link to comment https://forums.phpfreaks.com/topic/86352-newbie-php-code-help/#findComment-441260 Share on other sites More sharing options...
nsr500rossi Posted January 16, 2008 Author Share Posted January 16, 2008 Sorry about the lack of tags. Well i added the Ecofair to the _2006 code in my xml file and it worked. So i know that it can work, but i still have the problem of generating the images.xml file correctly. It is still shortening my thumbnail file name. Still need help please Mike Quote Link to comment https://forums.phpfreaks.com/topic/86352-newbie-php-code-help/#findComment-441336 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.