![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
Alex
Staff Alumni-
Posts
2,467 -
Joined
-
Last visited
Everything posted by Alex
-
Are you completely positive the request is getting to the file? If you really do have error_reporting(E_ALL); at the top of your file you should be receiving errors right now because unlike the ereg functions the PCRE functions require delimiters. Ex: preg_replace("[^A-Za-z0-9 ]", "", $name); should be: preg_replace("~[^A-Za-z0-9 ]~", "", $name);. You should change all of the other patterns accordingly.
-
By the way, there's a feature to mark a topic as solved. To do so there's a button at the bottom left.
-
Judging by the print_r of the $list array you should be using $list[0]['Type'] not $list['Type'][0].
-
m is for the month. We're currently in November, the 11th month so that's why it's displaying that. Instead change m to i
-
Remove __ amount of characters?
Alex replied to Graxeon's topic in Editor Help (PhpStorm, VS Code, etc)
Notepad++ actually supports Regular Expressions. If you press Ctrl + F then goto the replace tab you can check the box that says "Regular Expressions". Then search for: $[^"]* and replace it with nothing you'll be left with what you want. -
It seems this has evolved into more of an ActionScript problem, unless you can confirm that the values are being sent to the PHP file. It appears that you're using AS2.0, the majority of my ActionScript knowledge lies with AS3.0, but if you post your entire ActionScript source I can try to help you.
-
Perhaps that why it's you "all the time" then. ALEXWD has been being a rude person to me lately but i cant report him? Cause he's mod... I hope you're joking :-\
-
I should stop trying to do 23940748 things at once, sorry. function grab_files($start_dir, $ext) { $dir = new RecursiveDirectoryIterator($start_dir); $files = Array(); foreach($dir->getChildren() as $file) if(is_dir($file)) $files = array_merge($files, grab_files($file, $ext)); else if(pathinfo($file, PATHINFO_EXTENSION) == $ext) $files[] = (string) $file; return $files; } $files = grab_files('../gallery', 'jpg'); shuffle($files); array_splice($files, 20); foreach($files as $file) { echo $file . '<br />'; } Silly mistake.
-
I actually edited my post before you said that because I noticed that design flaw myself (if the first file found is a directory that will happen). Copy the code that's there now and it should work.
-
I'm not sure if this class implements an easier way to do this, there isn't documentation about it in the manual, but I don't think so. Something like this will work: function grab_files($start_dir, $ext) { $dir = new RecursiveDirectoryIterator($start_dir); foreach($dir->getChildren() as $file) if(is_dir($file)) $files = array_merge((array) $files, grab_files($file, $ext)); else if(pathinfo($file, PATHINFO_EXTENSION) == $ext) $files[] = (string) $file; return $files; } $files = grab_files('../gallery', 'jpg'); array_splice(shuffle($files), 20); foreach($files as $file) { echo $file . '<br />'; } Edit: Added the 20 file limit and randomization, forgot you wanted that as well.
-
Why not use glob. $files = glob('*.jpg'); array_splice(shuffle($files), 20); foreach($files as $file) { echo "$file<br />\n"; }
-
Variables aren't parsed in single quotes. Use double quotes: header("Location: index.php?id=$id");
-
You're misspelling some of the variables in the array, but yea that's the general idea.
-
I suggest you put error_reporting(E_ALL); at the top of your file. You should be getting a mysql error like 'column count doesn't match value count', because you're specifying 8 columns to insert into, but only providing 7 values. If `ID` is an auto_increment field it's not even necessary to include it in your query, so just remove it. [ot]You shouldn't be using ereg functions anymore as they're depreciated, instead use the PCRE functions. In your case preg_replace.[/ot]
-
That won't work. It'll give output like: first iteration: name1, name1; second iteration name2, name2; third name1, name1, etc.. I think you mean something like this: $x = 1; for($i= 0;$i < 4;$i++) { $x = ($x < 4) ? $x : ($x = 1); someFunction(${'var'.$x}, ${'var'.++$x}); $x++; } If you're going to do it that way might as well put $x inside the for()'s parameters to make it cleaner (like below). But I was under the impression that the OP wanted it to be random. for($i= 0, $x = 1;$i < sizeof($somevar);$i++, $x = (++$x < 4) ? $x : 1) someFunction(${'var'.$x}, ${'var'.++$x});
-
Implementations? Do you mean tutorials? There are examples of implementations all over the place, just look at Google or whatever. Here is a good tutorial, http://www.phpfreaks.com/tutorial/basic-pagination
-
You want to loop through the entire $links array and randomly choose the user/pass combination? Then do something like this: $arr = Array( Array( $_POST['note1'], $_POST['com1'] ), Array( $_POST['note2'], $_POST['com2'] ) ); for($i = 0, $c = count($links);$i < $c;$i++) { $curl = $turl[0].$links[$i]["href"]; $lcontent = getcontent($curl); $content = getthreadcontent($lcontent); $rand = array_rand($arr); something($content, $arr[$rand][0], $arr[$rand][1]); }
-
You can get values from the query string using the $_GET superglobal. somepage.php?var=something would be accessed like so: echo $_GET['var']; // Something
-
What about something like this? $arr = Array( Array( $_POST['note1'], $_POST['com1'] ), Array( $_POST['note2'], $_POST['com2'] ) ); for($i = 0, $c = count($arr);$i < $c;$i++) { $curl = $turl[0].$links[$i]["href"]; $lcontent = getcontent($curl); $content = getthreadcontent($lcontent); something($content, $arr[$i][0], $arr[$i][1]); } As long as you're excluding content it's hard for me to understand exactly what you're trying to do.
-
I'm not sure why you have that second for statement, or what you're trying to do at all. Can you post your entire code and explain what you're trying to do a little better?
-
You could do something like this: $arr = Array( $_POST['note1'], $_POST['com1'], $_POST['note2'], $_POST['com2'] ); for($i = 0, $c = count($arr);$i < $c;$i+=2) { something($arr[$i], $arr[$i+1]); }
-
You mean something like this? <script type="text/javascript"> var customMessages = new Array('Message 1', 'Message 2', 'Message 3', 'Message 4', 'Message 5'); var secondsPassed = 0; function myFunc() { var t = setTimeout("load()", 1000); } function load() { document.getElementById("ss2").innerHTML = 'Loading..' + customMessages[secondsPassed]; if(++secondsPassed < 6) var t = setTimeout("load()", 1000); else document.getElementById("ss2").innerHTML = 'Loaded!'; } </script> <body onload="myFunc()"> <div id="ss2">Loading..</div> </body>
-
What version of PHP are you running?
-
No, like this: date_default_timezone_set('America/Los_Angeles'); $time = date(F." ".d.", ".Y." ".g.":".i.":");