Re: Re: Question regarding fopen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Small correction $i = 4, means the last photo not 5..
Not so important but still.:P

2008/5/1 Joep Roebroek <j.roebroek@xxxxxxxxx>:
> This problem is getting stranger by the minute.
>  I will explain in a little more detail what the script is actually for..
>  It is an advert site and per advert, you can add 5 photo's..
>
>  Now you set the $i = 2; When I set the $i (which indictates the index
>  of the photo, so $i = 5; is the last photo) myself, it works..
>
>  But normally I get the $i from the database, because there is stored
>  how many photo's the already are in the advert.. When I use that value
>  it doesn't work at all.
>
>  When i set $i = 2.. It works :S,, but when the value it gets from the
>  db also is 2 than it doesn't work (it is like it just doesn't want me
>  to get it working :P)...
>
>  Reproduction would be very difficult, because it is in this very
>  specific situation...
>
>  Maybe I am able to give you access to the FTP but that is a bit risky
>  for me, not that I don't trust you, but the website is not mine..
>
>  regards,
>
>  Joep
>
>
>
>  2008/5/1 James Dempster <letssurf@xxxxxxxxx>:
>  > Do you have a piece of example code that will reproduce the problem?
>  >
>  > --
>  >  /James
>  >
>  >
>  >
>  > On Thu, May 1, 2008 at 12:26 PM, Joep Roebroek <j.roebroek@xxxxxxxxx> wrote:
>  > > Strangely enough.. It does.. But I have also tried adding a letter
>  > > (which gives me the good result) and then renaming it... But then the
>  > > value is wrong again :S
>  > >
>  > > I've never had a problem like this.. Very strange..
>  > >
>  > > 2008/5/1 James Dempster <letssurf@xxxxxxxxx>:
>  > >
>  > >
>  > >
>  > > > <?php
>  > > >
>  > > > $foldersystem = getcwd().'/test1';
>  > > >  $id = '54961';
>  > > > $imgstr = 'tdtdtdtd'; //uniqid();
>  > > >  $i = 2;
>  > > >
>  > > >
>  > > > $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i .
>  > '.jpg';
>  > > >  echo $imagenamesmall; // For debugging purposses --> returns exactly
>  > what I
>  > > > want.
>  > > >
>  > > >  //attempt to create folder
>  > > > mkdir($foldersystem);
>  > > >  chmod($foldersystem, 0777);
>  > > >
>  > > > //save picture
>  > > >  if(!($handle = fopen($imagenamesmall, 'w'))){
>  > > >    echo "Cannot open file (31)";
>  > > >     exit;
>  > > > }
>  > > >
>  > > >  This code works for me. How about you ?
>  > > >
>  > > > --
>  > > >  /James
>  > > >
>  > > >
>  > > >
>  > > > On Thu, May 1, 2008 at 11:04 AM, Joep Roebroek <j.roebroek@xxxxxxxxx>
>  > wrote:
>  > > > >
>  > > > >
>  > > > >
>  > > > > Does anyone have an idea? Is this a bug in PHP? Because when I add or
>  > > > > remove one static letter in the filename, it does work. And if I don't
>  > > > > the file is created, but the $imgstr (random 8 characters) is replaced
>  > > > > by a totally different value (also random 8 characters).. I have no
>  > > > > idea where this new value comes from.
>  > > > >
>  > > > > regards,
>  > > > > Joep
>  > > > >
>  > > > > 2008/4/29 Joep Roebroek <j.roebroek@xxxxxxxxx>:
>  > > > >
>  > > > >
>  > > > >
>  > > > >
>  > > > >
>  > > > >
>  > > > > > Hi, I'm having a strange problem with fopen
>  > > > > >
>  > > > > >  For clearence, here is the phpinfo page:
>  > > > > >  http://www.grondengoed.nl/phpinfo.php
>  > > > > >
>  > > > > >  I will shortly explain the problem I'm having:
>  > > > > >         $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s'
>  > .
>  > > > > >  $i . '.jpg';
>  > > > > >         echo $imagenamesmall; // For debugging purposses --> returns
>  > > > > >  exactly what I want.
>  > > > > >
>  > > > > >         //attempt to create folder
>  > > > > >         @mkdir($foldersystem);
>  > > > > >         @chmod($foldersystem, 0777);
>  > > > > >
>  > > > > >
>  > > > > >         //save picture
>  > > > > >         if(!($handle = fopen($imagenamesmall, 'w'))){
>  > > > > >             echo "Cannot open file (31)";
>  > > > > >             exit;
>  > > > > >         }
>  > > > > >
>  > > > > >        //$imagesmall, contains the image resource
>  > > > > >
>  > > > > >         if(fwrite($handle, $imagesmall) === FALSE) {
>  > > > > >             echo "Cannot write to file (32)";
>  > > > > >             exit;
>  > > > > >         }
>  > > > > >
>  > > > > >         fclose($handle);
>  > > > > >
>  > > > > >  Erverything works perfectly fine.But one thing, it doesn't give the
>  > > > > >  file the name that it should get. A name for instance has to be:
>  > > > > >  54961tdtdtdtd-s0.jpg
>  > > > > >  The number is the id of the database row, the 8 characters are
>  > random.
>  > > > > >  -s stands for small and 0 is the picture index.
>  > > > > >  When I echo the value, I get what I want. But when I save it, the
>  > > > > >  random 8 character string had become a totally different 8
>  > character
>  > > > > >  string :S.
>  > > > > >
>  > > > > >  I have googled and checked things over and over again, cost me
>  > hours
>  > > > > >  and I still haven't found the reason. What is noticeable is that
>  > when
>  > > > > >  I leave one character away from the name, the value IS what it
>  > schould
>  > > > > >  be:S.
>  > > > > >
>  > > > > >  I really hope you can help me, if you need further info yust ask.
>  > > > > >
>  > > > > >  Thanks in advance.
>  > > > > >
>  > > > > >  regards,
>  > > > > >
>  > > > > >  Joep Roebroek
>  > > > > >
>  > > > >
>  > > > >
>  > > > > --
>  > > > > PHP General Mailing List (http://www.php.net/)
>  > > > > To unsubscribe, visit: http://www.php.net/unsub.php
>  > > > >
>  > > > >
>  > > >
>  > > >
>  > >
>  >
>  >
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux