Jump to content

Chappers

Members
  • Posts

    119
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Chappers's Achievements

Member

Member (2/5)

0

Reputation

  1. It means what it says... because I dislike Firefox I do not use it ever. But, to test this problem, I launched it to look at my website to see if it was showing the changes that I'd made which weren't showing in IE. I have not launched Firefox since purchasing the domain name and server space for my website, ergo it has not ever been used for this website before, so this was the first time ever that my website has been viewed in Firefox. Clicked refresh more than a few times because it's extremely annoying that it won't update. Dozens of times is closer to the mark. Yes, tried compatibility too, but no difference, still shows the 'old' version. If I wait more than 10 minutes or so, just one click of 'refresh' will load the new (edited) page.
  2. Hi, Googled this, and although I find others complaining of it, it seems most people don't understand the problem, or simply don't know what causes it or the solution... I edit my HTML code and then upload to the website server using an FTP client. Changes I've made, such as turning a table border on, resizing and re-uploading an image, etc., do not show on the website for at least 10 minutes. I'm using IE. If, after making the changes to the HTML code and before IE shows those changes, I open Firefox to look at the website for the first time ever, even that doesn't show the latest changes. This would mean it's not local caching that's the trouble, wouldn't it? So, what mechanism is responsible? Is the ISP likely caching and if so, can I do anything about that from my end? Can I add something to the web page code that forces the ISP to ignore its cache and grab the page from the server each and every time the page is requested? Incidentally, CTRL+F5 makes no difference, nor pressing F12 and clearing browser cache and telling it to 'always refresh from server'. I know some people create webpages offline and view them that way, but I am familiar with this way and prefer it. And some pages have PHP code which needs the server since I haven't got anything installed on the computer for it. Any help much appreciated
  3. Thanks wildteen88, works perfectly now.
  4. Using flashfxp, I FTP'ed to the website and right-clicked and chose make folder. @PFMaBiSmAd: Two problems with your post; the LOL which is patronising, but since you obviously know so much, I'm sure it's acceptable to take the p*ss out of those who don't. Second problem; if you read my post including the code output, you'd see is_dir ISN'T returning TRUE for everything it finds like you claim it must do.
  5. Hi, I've read of is_dir problems in older versions of php, so checked and server is using 5.2.13. This simple bit of code: <?php $contents = scandir('/home/*******/public_html/images/'); foreach ($contents as $content) { if (is_dir ($content)) { echo "$content is a directory<br>"; } else { echo "$content is NOT a directory<br>"; }} ?> outputs: . is a directory .. is a directory folder1 is NOT a directory folder2 is NOT a directory folderthree is NOT a directory Those are the three folders I created for test purposes. Is_file works as anticipated, and I know I can use it and other workarounds. But why wouldn't is_dir be working? Have I done something wrong?
  6. No idea why, but removing the back slash from the end of the folder name variable %date% fixed it. So (move "%~1" "%date%\") became (move "%~1" "%date%"). Strange that with set /a it wasn't an issue, but without the /a, it suddenly was and caused 'specified path not found' errors.
  7. Hi, I wonder if anyone could please spare the time and energy to help me? I wanted to sort the 400 or so photos of my son by the month and year they were taken, as the info is in the photo file. I googled and found a similar block of code used to sort images by size, and quickly learnt a little about batch file commands to alter it to grab the image month and year data instead, and then create folders using the month and year as the folder name, and sort the files into the respective folders. Anyway, I found a flaw: after creating a file containing the image info, this code grabs the date and month in numerical form: for /f "tokens=3,4 delims=/" %%a in ('type %info% ^| find.exe /i "File date"') do (set /a month=%%a) & (set /a year=%%b) I found it failed to grab the month sometimes, and after much googling and reading the set/? help, finally discovered the /a after set means it is treating numbers beginning with 0 as octals. Since 08 isn't an octal, it was failing when the month was 08. So, I removed the /a option and it now grabs 08 as it should, but doesn't do what it's supposed to do. It creates the folder with correct name (such as 08_2011) but doesn't move the image file into the folder. The CMD prompt just states "can't find specified path" or something like that. If I replace the /a after set, it works albeit without the month present, so folder name becomes "_2011". Can anyone help? Why doesn't it just assign the data to a variable like PHP?! Here's the whole code for anyone requiring it: Thanks @echo off cls setlocal :: Temp-/Infofile path/name set info=%temp%\info.txt :: Dimension file path/name set dims=date.txt :: IrfanView set iview=C:\Program Files\IrfanView\i_view32.exe :: File extensions set filext=*.jpg *.tif for %1 %%a in (%filext%) do call :EXTRACT "%%a" goto :END :EXTRACT "%iview%" %1 /info="%info%" for /f "tokens=3,4 delims=/" %%a in ('type %info% ^| find.exe /i "File date"') do (set /a month=%%a) & (set /a year=%%b) echo File: %~1 >> "%dims%" echo Month: %month% >> "%dims%" echo Year: %year% >> "%dims%" set date=%month%_%year% if exist %date% (echo Moved to existing folder >> "%dims%") & (move "%~1" "%date%\") else (echo Moved to new folder %date% >> "%dims%") & (MD %date%) & (move "%~1" "%date%\") echo. >> "%dims%" goto :EOF :END if exist %info% del %info% endlocal
  8. Excellent, many thanks for your time and help. I've been able to learn from that and do my own code now, to suit my needs. I hadn't come across the FOR function before. Thanks again, I owe you one.
  9. Hi, I'm writing my own code for my website but have come across something I can't fathom and don't know what search terms I'd need to describe what I want, to allow me to Google it. I've got some code that retrieves the image names of pictures inside a directory, that then prints them on the screen as links. Then people can click whichever link to see that pic, and I can just upload new images to the images folder without needing to add the links to the code manually. All is working, but I want to use a table for neatness and put a certain number of the image links in each row. So, say I have 20 images in the folder, but want to display only 5 image links per row in the table, I need 4 rows to be created with 5 links in each one. I know I can use count() to count the number of images found in the folder, but I don't know how to use PHP to make a new row every 5 image links and put the 5 links in the row. This is my code so far: <?php $dir = '/home/vol7/myhost.com/b12345678/htdocs/images/'; $files = scandir($dir); foreach ($files as $pic) { if (is_dir($dir.$pic)) { unset($pic);} else { echo "$pic"; }} ?> So, if I got it doing what I want, it'd end up outputting something like this if I had 7 image links: <table> <tr> <td><a href=etc">image 1</a> - <a href=etc">image 2</a> - <a href=etc">image 3</a> - <a href=etc">image 4</a> - <a href=etc">image 5</a></td> </tr> <tr> <td><a href=etc">image 6</a> - <a href=etc">image 7</a></td> </tr> </table> Any help appreciated, even a link to a webpage explaining something similar that gives me enough information to alter it and make it work for what I want. Thanks.
  10. Thanks for that, really appreciate your time and help. I'm very novice at this, but don't have much time for learning deeply due to work hours, family, etc. My job is unrelated to computers and programming so I have to try and cram a bit of this into my brain when and if I can. I always try to do things myself because I get the feel good factor from that, but sometimes I don't have the time to learn enough to do it myself. And most of the time it's for basic websites I knock out for my own amusement or just to help spread information on subjects important to me. Hobby only, really. It's taken me till now (3am here!) just to sort out this IP problem and I have work in the morning! Oh well. Thanks again.
  11. Shame it assumes that and doesn't even have a link for regular expressions. I don't see how it can explain a function with the assumption you already know about it, seems paradoxical. Anyway, thank you but regular expressions still didn't help me with how to get the function to only replace integers after the second full-stop (dot). I believe it's known as using delimiters but Google just brings up thousand of pages of people doing things with delimiters exactly unlike I need to do, and often complex as hell. So I knocked this up which is adequate even if it replaces the actual number of integers after the dot with a string of 6 asterisks, and not the correct number. <?php $ip = '84.254.142.163'; $needle = '.'; $replacement = '***.***'; echo "IP before: $ip<br>"; $pos = stripos ($ip, $needle, $offset = 4); $pos = $pos + 1; $new_ip = substr_replace ($ip, $replacement, $pos); echo "IP after: $new_ip"; ?>
  12. Hi, I'm trying to use preg_replace to remove part of the IP address submitted using a form on my website. The full IP is entered into my SQL database, but when printing it on the website I want to remove some numbers, so turn for example: 82.132.196.45 into 82.132.***.** when printed on the page. I find preg_replace very hard to use, though, and the PHP manual isn't very helpful for those who don't know what all the /wd<>\\n type things mean. I need to not only match numerals and replace each numeral with an asterisk, but get preg_replace to ignore the first two groups of numbers. I know this means telling the function to only pay attention to anything after the second dot, but don't know how. Can anyone assist please?
  13. Hi, Using IE8 and finding that if I make a change to a property in my CSS stylesheet and then upload it, I can't get the change to reflect in IE until it feels like it, usually a long time later. Tried what used to work in older versions of IE (CTRL + F5), but it's not helping. Weirdly, I made a change to the stylesheet and found it wouldn't show in IE. So I clicked on the compatibility view thing, and that showed the page with my latest changes. Now, when I click between normal view and compatibility view, it's showing the page with old and later stylesheet properties. However, my last change to the stylesheet won't show on either view. Tried closing and re-opening browser, tried emptying temp files - even found and deleted the copy of the stylesheet from the temp folder but no difference. What I don't get is that IE obviously has two copies of the stylesheet lingering, one which is being used when I am in normal view mode, and one when I'm using compatibility view. Yet a search showed only one copy residing in temp internet files, and even getting rid of that didn't work, as I said above. Any ideas please?
  14. Hi, that isn't the whole script, just the part I was struggling with. I since found out myself that every field, used or not, gets assigned a key, and of course the error code 4 for every empty field. It was that error code that allowed me to overcome the problem. Here's the entirety of what I've come up with (took me ages, I'm still learning...), although I haven't included the code for other checks and actual copying of files to destination folder as I need to integrate this code to my original upload form. Any criticism welcome to help educate me, but please keep it light as I am learning and may have overcomplicated things. I've made the form so that the user can add upload fields up to a preset maximum, and the remaining number of fields that can be added before maximum reached is reflected in the choice from the dropdown select list. I wanted to ascertain which fields had actually been used for an image so that each empty field didn't come up with 'no file selected'; I only want that to come up if all fields are left empty. Seems to be working fine. Look forward to thoughts on it! <?php // Set these two variables to preference $image_fields = 1; // Number of fields to show initially $total_fields = 10; // Total number of fields allowed if (isset($_POST['addfields'])) { // If ADD button has been clicked $current_fields = $_POST['current_fields']; // Fields already displayed at time of adding $add_fields = $_POST['add_fields']; // Number of fields selected to add $img_fields = $current_fields + $add_fields; // New number of fields to display } else { $img_fields = $image_fields; // Show predefined number of fields at page load } if(!isset($_POST['upload'])) { // If UPLOAD button has not been clicked echo <<<JQB <form name="upload" enctype="multipart/form-data" method="POST" action="{$_SERVER['PHP_SELF']}"> <table class="submitform" align='center' width="30%" cellspacing="0" cellpadding="0" border="1"> JQB; $x = 0; while ($x < $img_fields) { // Repeat until img_fields value has been reached echo <<<JQB <tr> <td><span class="field-names">Image file:</span></td> <td><input class="fields" type="file" name="file[]" value=""></td> </tr> JQB; ++$x; // Add 1 to previous value of $x each loop } // End of while loop echo <<<JQB <tr> <td><input type="hidden" name="num_fields" value="{$img_fields}"></td> <!-- Number of fields for NO FILE check later--> </tr> <tr> <td colspan='2' align='center'><input class="button" type="submit" name="upload" value="Upload"></td> </tr> </table> </form> <form name="addfields" enctype="multipart/form-data" method="POST" action="{$_SERVER['PHP_SELF']}"> <table class="submitform" align='center' width="30%" cellspacing="0" cellpadding="0" border="1"> <tr> JQB; if ($img_fields < $total_fields) { // If displayed fields are less than total permitted echo <<<JQB <td>Add <select name='add_fields' size='1'> JQB; $xx = 0; $current_fields = $img_fields; // Copy displayed fields before while loop changes its value while ($img_fields < $total_fields) { // Repeat while displayed fields is less than total limit ++$xx; // Add 1 to previous value of $xx each loop echo <<<JQB <option value=$xx>$xx</option> // Use value of $xx at each loop for each option value shown JQB; ++$img_fields; // Add 1 to number of fields each loop so limit can be reached } echo <<<JQB </select> more upload fields</td> </tr> <tr> <td><input type="hidden" name="current_fields" value="{$current_fields}"></td> <!-- Fields now going to be displayed--> </tr> <tr> <td align='center'><br><input class="button" type="submit" name="addfields" value="Add"></td> JQB; } else { // If total permitted fields already displayed then echo "<td>No more fields can be added</td>"; // display this instead of options } echo <<<JQB </tr> </table> </form> JQB; } else { // If UPLOAD form has been submitted $num_fields = $_POST['num_fields']; while (list($key,$value) = each($_FILES['file']['name'])) { // Assign a key to the name of each uploaded file $fileerror = $_FILES['file']['error'][$key]; // Variable containing error numbers if ($fileerror == 4) { // Do this if error 4 (no file) given $nofile[] = 'no file'; // Add the error to the variable array } } $no_images = count($nofile); // Count number of variables in array and put result in this variable if ($no_images == $num_fields) { // Do this if number of fields submitted with NO FILE error is equal to echo "No file selected"; // total number of fields submitted (meaning all were empty) } else { // If NO FILE fields submitted was less than total fields $fields_used = $num_fields - $no_images; // submitted then at least one field had a file selected } $y = 0; // Keys start from zero ($y), but count must start from minimum number $yy = 1; // of fields used, which is one ($yy). while ($yy <= $fields_used) { // Loop code until number $yy reaches number of fields used $filename = $_FILES['file']['name'][$y]; // Variable for original name of file uploaded $filetemp = $_FILES['file']['tmp_name'][$y]; // Variable for temporary file name given by server $filetype = $_FILES['file']['type'][$y]; // Variable for type of file uploaded $filesize = $_FILES['file']['size'][$y]; // Variable for size in bytes of file uploaded $fileerror = $_FILES['file']['error'][$y]; // Variable for error codes assigned to upload ++$y; // Add 1 to number each time loop runs for key number ++$yy; // Add 1 to number each time loop runs for count towards fields used // From here on, code to perform additional checks and then copy image to your destination folder can be put. echo "Filename: $filename<br>"; echo "Temp Filename: $filetemp<br>"; echo "Filetype: $filetype<br>"; echo "Filesize: $filesize<br>"; echo "File Error: $fileerror<br><br>"; } } ?> Thanks for everyone's help, without it I wouldn't have got this far even.
  15. Thanks for that, I've read the page and will implement the default errors that come with uploading files. Out of interest, do you know what was going wrong when I was checking to see if the variable was empty, yet it was saying it wasn't empty despite not having chosen a file in any of the upload fields?
×
×
  • 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.