|
I would like to sort file names with file extensions numerically. It's not sorting correctly right now, and I think it is because of the file extensions. So far I have: code:
|
# ¿ Apr 16, 2008 19:53 |
|
|
# ¿ May 15, 2024 01:37 |
|
duz posted:You probably want to do a Natural Sort. Yes! This is awesome. Exactly what I wanted. Now, I'm trying to make it go in reverse order like before, and I can do it but I don't know if it's the best way because it seems to be working very slow, but then again it could just be my internet connection. code:
|
# ¿ Apr 16, 2008 22:05 |
|
gibbed posted:Also suggesting use of glob() instead of the opendir crap. But do I really need it? Is there a reason this would be better in my situation?
|
# ¿ Apr 16, 2008 22:07 |
|
duz posted:It's slow because you're reversing the array each time you loop. Yeah I see that, but even if I put the array_reverse($files) after natsort, it won't permanently do anything because its not resorting the array. Also putting rsort after the natsort will do away with the natsort. It doesn't seem too bad now, and maybe it was just my connection, but is there a better way I should do this?
|
# ¿ Apr 16, 2008 22:26 |
|
duz posted:Read the docs. array_reverse returns the reversed array. You'll need to do $files = array_reverse($files);. Well that was all too obvious. Thanks. I probably would have thought to do that after taking a break, but yes it does work a bit faster.
|
# ¿ Apr 16, 2008 22:56 |
|
gibbed posted:Also suggesting use of glob() instead of the opendir crap. Okay, glob is way better you're right. Gets rid of a lot of code and I don't have to tell it to open or close the directory. Definitely using this from now on. Thanks.
|
# ¿ Apr 19, 2008 06:52 |
|
I was using php code to check if a sent $_GET didn't come from outside of my website. Now I want to do the same thing with $_POST, and I expected the code to work for it, but it doesn't do anything inside the if statement if a $_POST occurred. I tested to make sure this was the case by echoing the sent $_POST outside of the if statement, which works. Here's the code I used to validate a $_GET: code:
LP0 ON FIRE fucked around with this message at 22:19 on May 2, 2008 |
# ¿ May 2, 2008 22:16 |
|
Lumpy I tried your test and it failed.
|
# ¿ May 2, 2008 22:40 |
|
I figured out the HTTP_REFERER issue. I don't know if this was obvious to any of you, but when you use $_POST as opposed to $_GET, you actually have to specify the ENTIRE address, not just the file name even if it is in the same directory to be able to send the HTTP_REFERER information and get it back with $_POST. Of course the information for the $_POST will return, but not the HTTP_REFERER.
|
# ¿ May 3, 2008 06:21 |
|
edit sorry wrong thread.
LP0 ON FIRE fucked around with this message at 18:52 on May 3, 2008 |
# ¿ May 3, 2008 18:49 |
|
If header( 'Location: example.php' ); is placed at the top of a PHP script outside of a function, if statement or any other logic is the rest of the code guaranteed to run properly before it performs the header redirect?
|
# ¿ May 5, 2008 18:11 |
|
Mashi posted:I don't know about guarenteed to run properly (that would be nice wouldn't it?) but outputting a header will not disrupt the execution of your script at all. Okay, good to know. Thanks.
|
# ¿ May 5, 2008 18:37 |
|
noonches posted:You can still used ob_start() and ob_end_clean() and output a header at any point. I'll try this out too. I'm just trying to debug something. For some reason when I when I have the header there SOMETIMES my information that goes to another part of the site doesn't actually go there, and I was just wondering if it was because of something in the header that wasn't giving the site enough time to get the information it needed or something.
|
# ¿ May 5, 2008 19:46 |
|
I'm using imagepng to create PNGs out of code into a certain directory. That all works fine, but why on the page where i use imagepng it spits out weird characters and how do I get rid of them? To see what I mean, just draw some nonsensical thing on the page, type in the CAPTCHA and then the page where it says it was successful shows that mess. Just to let you know, depending what people have made, might be considered not work safe. But they are just pixelated small images. http://www.majoroutput.com/TestMOCode2/index.php edit: I don't know if there's any alternate way of using it, but here's the line of code: imagepng($thumb, "blocks/".$numOfFiles.".png"); If I get rid of that, it takes away the characters. LP0 ON FIRE fucked around with this message at 02:25 on Oct 26, 2008 |
# ¿ Oct 26, 2008 02:19 |
|
Internet Headache posted:I'm not sure why imagepng would function that way. As a short-term hack for a library of hacks, you could use output buffering around the function and just dump the contents. Excellent! It works, thank you.
|
# ¿ Oct 26, 2008 03:51 |
|
dagard posted:Apropos of nothing, please, don't do that. Fan out your directories, don't put everydamnthing in one directory. readdir() calls will start beating the hell out of your performance. A better way would be, let's say $numOfFiles is 38234234, write it to: Thanks. Yes, it will eventually go to different directories. I never thought of the way you suggested, so thank you. edit: Isn't that scaling way further into the trillions of possible files? LP0 ON FIRE fucked around with this message at 00:07 on Oct 27, 2008 |
# ¿ Oct 26, 2008 21:09 |
|
mysql_real_escape_string is making variables blank for me. For instance, I have: $nameVar="test"; $nameVar=mysql_real_escape_string($nameVar); echo "name".$nameVar; I found was now inserting nothing into my database and echos nothing back. Anyone know what could cause this issue?
|
# ¿ Oct 28, 2008 07:00 |
|
Strong Sauce posted:Possibly this, Ah! I remember reading that somewhere. Thanks!
|
# ¿ Oct 28, 2008 07:15 |
|
This is a mixed php/Actionscript 2/MySQL question. PHP is echoing back a variable queried from MySQL just fine, called $imageSourcesString. When gets the variable with loadVariables, it returns empty in Flash. If I redefine $imageSourcesString in php as $imageSourcesString="test"; its sent to Flash just fine. Why can the original variable echo in php, but not be sent to Flash? I've tried adding quotes, characters around the original, etc. Say if I redefine it as $imageSourcesString="A".$imageSourcesString."A"; in Flash it shows up as "AA". I can see that $imageSourcesString echos in php perfectly alright as the image names. What the hell? Is $imageSourcesString not a proper string for Flash or something coming from MySQL?
|
# ¿ Jan 7, 2009 21:11 |
|
Lumpy posted:It needs to be a URLecoded string... your problem seems odd though. Are you trying to output the string $myVar=A[$myvar's value]A as a result? Using echo $imageSourcesString in php shows result. In Flash, it shows nothing. Doing this however after its defined: (I'm redefining the variable) $imageSourcesString="test text"; Shows this in Flash: test text Say if my variable $imageSourcesString equaled "123456789" as a result from the database. If I redefine it as: $imageSourcesString="A".$imageSourcesString."A"; In php it shows "A123456789A" In Flash it shows "AA" I was starting to think it had to do with register_globals being enabled. I'm currently using php 4 and after trying to change it to off, GoDaddy notified me I won't be able to do this unless I'm using php 5, which doesn't seem right. I swear I changed that setting before in php 4 on another server. Maybe its just the way GoDaddy does things. This is really blowing my mind though and I'm starting to think it has to do with some weird thing occurring with register_globals.
|
# ¿ Jan 7, 2009 23:11 |
|
Munkeymon posted:OK, but what does Flash get when you do $imageSourcesString=urlencode($imageSourcesString);? Same thing, still nothing.
|
# ¿ Jan 8, 2009 00:18 |
|
awdio posted:Using echo $imageSourcesString in php shows result. I finally figured out what was causing the problem, but I don't know WHY it happens. I had a variable defined with a get: $catNum=$_GET['catNum']; If I simply make that variable a number and not the get my other variable from the database gets sent to Flash. Why?? $catNum=3; Edit: Basically, if I have that variable $catNum defined with the get $_GET['catNum'], $imageSourcesString does not pass to Flash! If I make $catNum equal say, "3", everything works. But I NEED the get for $catNum. LP0 ON FIRE fucked around with this message at 04:52 on Jan 8, 2009 |
# ¿ Jan 8, 2009 03:10 |
|
Standish posted:Looks like Flash is not supplying the "catNum" parameter in its GET query string for some reason, try running wireshark to see exactly what's going over the wire. But why would it need to? Flash is NOT getting the variable $catNum. It's getting $imageSourcesString. I'd try WireShark, but I don't think there's a non-Intel Mac version.
|
# ¿ Jan 8, 2009 18:48 |
|
I guess the question I should be asking is: How do you pass a variable with GET from one page to another (or even the same page) and have Flash load that variable in? I'm just passing it with the same page, but I've also tried passing it to another page. PHP gets it. Flash does not. If I just make a non-POST or non-GET variable it passes to Flash fine. If you think this normally should be done, try it out, because I'm starting to think it can't be done.. Edit: Its as if Flash is being loaded before the POST or GET vars.
|
# ¿ Jan 9, 2009 07:09 |
|
Lumpy posted:I'm confused now. Works like this: I click on a URL that goes back to itself with a variable attached like so: http://pageurl.com/index.php?catNum=9 So when the page reloads, php sees that catNum is set, then does a mySQL query based on the catNum to form a variable to send to Flash - a list of images with a delimiter that Flash breaks down. The variable is called $imageSourcesString and is put into a hidden text field that Flash picks up with loadVariables. For some reason this isn't working BUT if I ignore the GET on the page reload and just set $catNum to a number everything else works fine. i.e. $catNum=12 instead of $catNum=$_GET["catNum"] Interestingly enough its not getting stuck until the Flash stage of things. PHP can still pick up the results of the image string based on the GET. LP0 ON FIRE fucked around with this message at 22:27 on Jan 9, 2009 |
# ¿ Jan 9, 2009 22:15 |
|
Lumpy posted:Can you give us a real URL. I think I know what your poblem is, but I can't be sure unless I see WTF. http://www.donnastangerphotography.com/dbFormat/indexTest.php?catNum=12
|
# ¿ Jan 9, 2009 22:50 |
|
I've been trying so many things. I even tried putting the URL into a variable and using explode to get the value after the equals sign, echoed the value to make sure php got it, and it still breaks Flash. I also tried making javascript function that fills in a div with the Flash code after a timed interval but it behaves exactly the same.
|
# ¿ Jan 11, 2009 00:30 |
|
Ghotli posted:Have you tried a small proof of concept completely separate from the code you've been working with? If all you need is for flash to receive the value of a php variable you can mock up this situation in very few lines of code. This should help isolate the problem. My guess is there's a problem with your code that you're overlooking because you have been debugging for too long. Step back, relax, and write a simple proof of concept. This will help you see if it works on that server/browser at all or if it's a specific problem with your code. Yes. And I can get a php variable into Flash. Its the GET variable in a mysql query is what causes things to get hung up. If I define the variable without the GET, it does not happen. I can echo back the correct results of the php query, the Flash just does not get anything from the result of the query. Read above for details. Also if people want a more direct way of looking at this, here's the php/html: code:
LP0 ON FIRE fucked around with this message at 01:34 on Jan 11, 2009 |
# ¿ Jan 11, 2009 01:24 |
|
Lumpy posted:How is the Flash supposed to get the stuff you generate to the hidden field? Magic? Why not tack on your vars to the end of the URL to the movie? Flash can get the stuff on the hidden field perfectly fine except when the initial variable from GET that SQL uses for a query is used. If I just simply defined the variable instead of using the value of GET everything would be fine. I'd explain how this works all over again but I've explained this in at least 3 other replies so far. Read those so you can understand what the problem is more. But thanks for your suggestion I'll try that. LP0 ON FIRE fucked around with this message at 05:12 on Jan 13, 2009 |
# ¿ Jan 13, 2009 04:33 |
|
Lumpy posted:Your replies are confusing at best. "Flash can get stuff out of hidden fields" doesn't make any sense whatsoever. Flash actionscript can use loadVariables("currentpageURL.php", this, "POST"); to get POST variables from the current page that it is on. You can make the value of hidden fields like so to make a POST variable like so: php:<? $variableSentToFlash="hello there"; echo "<INPUT type = 'hidden' name = 'Page' value='&variableSentToFlash=$variableSentToFlash'>"; ?>
|
# ¿ Jan 13, 2009 19:59 |
|
I've been using preg_match to only accept certain characters, but now I want to use it to accept certain characters AND spaces, but NOT leading spaces, and NOT more than one space in a row. Will that involve more than just preg_match? I've tried the following to just plain old accept spaces, but it doesn't work! On another forum they showed something similar: preg_match('%^[A-Za-z0-9_- ]+$%', $_POST["user"]) Notice the space after the "-"
|
# ¿ Feb 25, 2009 08:11 |
|
KuruMonkey posted:Question: do you really want to 'not accept' leading spaces and multiple spaces? Or just not have them in the final accepted string? This is some great information for fixing up the spaces. Only problem is that I haven't had preg_match work correctly at accepting spaces. It works other wise. php:<? if(preg_match('%^[A-Za-z0-9_- ]+$%', $_POST["user"])){ }else{ //return false } ?> That if will return false with $_POST["user"] with or without spaces.
|
# ¿ Feb 26, 2009 18:46 |
|
Thank you KuruMonkey and Munkeymon! I knew about escaping the - character but it never came to me when I saw that! Those condensed expressions are pretty awesome, but I have no idea what's REALLY going on in that, so I'll probably read up about it.
|
# ¿ Feb 26, 2009 20:40 |
|
I haven't been able to get a cookie work from a page in one directory to another page in the root directory. If it's in the root directory, it works page to page in the root directory. I use: $expire=time()+60*60*24*30; setcookie('user', $_POST["user"], $expire, '/', '.example.com'); LP0 ON FIRE fucked around with this message at 08:26 on Feb 27, 2009 |
# ¿ Feb 27, 2009 08:23 |
|
I've copied and resized a picture before in PHP, but for some reason the image is resizing the correct size but comes out all black. php:<?php define('filename', "testResize/testSource.png"); define('sizeIncreasePercent', 5); // Get new sizes list($width, $height) = getimagesize(filename); define('newwidth', $width * sizeIncreasePercent); define('newheight', $height * sizeIncreasePercent); // Load define('thumb', imagecreatetruecolor(newwidth, newheight)); define('source', filename); // Resize imagecopyresized(thumb, source, 0, 0, 0, 0, newwidth, newheight, $width, $height); // Output imagepng(thumb, "testResize/test.png");; ?>
|
# ¿ Mar 10, 2009 06:59 |
|
gibbed posted:What the gently caress? Why are you using define that way? I'm making constants for security reasons when I add onto the code. What exactly do you mean by image resource? Sorry for the dumb question, I just have no idea what you mean by this. I don't get any warnings or errors if I drop imagepng.
|
# ¿ Mar 10, 2009 07:17 |
|
gibbed posted:ImageCopyResized Excellent! Changing it to this: define('source', imagecreatefrompng(filename)); worked! It's exactly the effect I need. No softness or blurring. I don't have error reporting off.. I don't know why it didn't give me errors. Everything is fine now though, thank you. The script may be used in a form, and I just think it's good practice for data that isn't going to change throughout the script to use a constant. I don't have exact plans how I'm going to change this code, but I know the constants can remain constants without a problem. I read about the importance of using constants in a form as a security measure here: http://dev.mysql.com/tech-resources/articles/php-security-ch02.pdf LP0 ON FIRE fucked around with this message at 07:43 on Mar 10, 2009 |
# ¿ Mar 10, 2009 07:37 |
|
Why can't I get this simple script to work? All I want to do is take an image from a URL and store it to a folder on my server. The folder has the correct permissions and I've tried a manual image uploader to that same folder and it works. I've also wrote $fp as open('http://www.majoroutput.com/sonicCircus/images/', 'w'); (without the filename). php:<?php $contents = 'http://www.majoroutput.com/sonicCircus/test.jpg'; echo "<img src='".$contents."'>"; $fp = fopen('http://www.majoroutput.com/sonicCircus/images/test.jpg', 'w'); fwrite($fp, $contents); fclose($fp); ?> LP0 ON FIRE fucked around with this message at 23:26 on Aug 14, 2009 |
# ¿ Aug 14, 2009 23:02 |
|
waffle iron posted:Are you trying to use the http file io wrappers to write? If all these files are on your webhost, why don't you just use copy? It also looks like you're passing the wrong arguments to fwrite. I'm just using files on the same host as a test. I've tried off the site too. I've seen multiple people mention using fwrite to get offsite images and save them to your host, including: http://www.webmasterworld.com/forum88/374.htm
|
# ¿ Aug 15, 2009 02:28 |
|
|
# ¿ May 15, 2024 01:37 |
|
I'm doing what you wrote: defining $contents with file_get_contents and putting the URL into a variable, if that does anything. Doesn't work.
|
# ¿ Aug 17, 2009 06:25 |