-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
when you rightclick > view source, do you see correct ids or are they all outputting the same (last) id? where is your submit button in relation to this? What code actually submits the form? My *guess* is that since you don't have a submit button in each of the forms, you must have a single submit button and js doing something to submit. So the problem is likely somewhere in the js
-
Yeah but, what's the advantage of doing that over just doing $dataLine = explode("\t", $dataLine, 2); // do something with $dataLine[0] and $dataLine[1] I can think of several times to "use" it.. what I fail to come up with is a compelling reason to use it, as in, an instance where it's more efficient than any other way or something list can be used for that no other thing can do, etc. For example.. it might be "slightly better" if instead of having to supply an argument for every variable.. if you could pass it an array of values. Example: $vars = array('var1','var2','var3','var4','var5'); list($vars) = explode("\t",$dataLine,5); But you can't do that. And I say "slightly better" because again.. what's a real advantage for even doing this? Overall I'm kinda thinking that list() actually works against elegant coding. At best (e.g. your example) it's an unnecessary extra step or waste of variable namespace. At worst.. it actually goes against all the benefits of having stuff in an array to begin with. And thing is, I usually always see it being used in a context similar or exactly the same as OP: separating grouped data. Well it's almost certain that that data relates to each other on some level, so even if you have to act on individual elements, overall that data is more than likely gonna stay "grouped" 99% of the time.
-
off topic.. I honestly can't think of a single compelling reason to actually use list() ..
-
very first google search result for "Reduce the size of the above-the-fold content": https://developers.google.com/speed/docs/insights/PrioritizeVisibleContent
-
maybe it would be more helpful if you explain what you are actually trying to do here. It *seems* that you are wanting to make a bot that automatically clicks links on a given page.
-
use DOMDocument::loadHTMLFile to load the page and DOMDocument::getElementsByTagName to get the links off the page.
-
[WordPress] I'm completely New and having a tough time
.josh replied to mittymit6's topic in Applications
the file you posted only contains css, which has nothing to do with the error you are getting. -
if you are using cURL then you can use curl_setopt and set CURLOPT_USERAGENT if you are using something more generic like file_get_contents then you will have to set it in your php.ini file
-
Okay, then you can use the first pattern I showed: /SKU:\s(\S+)/ As I said, this will capture anything that is not a space. A more restrictive version based on your feedback could be: /SKU:\s([\w-]+)/ This will capture one or more "word" characters or hyphens But "word" characters include underscore, so even more restrictive would be: /SKU:\s([a-z0-9-]+)/i This will explicitly only match letters, numbers and hyphens. Notice I added the "i" on the end of there, after the closing delimiter. This is to make the match case-insensitive
-
\w is shorthand for a "word" character class, and is the equivalent of [a-z0-9_] which matches letters, numbers or underscore. It stops at "DD" because a hyphen isn't a "word" character. A liberal approach would be to do this: /SKU:\s(\S+)/ This will capture anything that is not a space. A more restrictive approach could be this: /SKU:\s(\w+-\w+)/ This will match one or more "word" characters followed by a hyphen followed by one or more "word" characters. An even more restrictive approach could be this: /SKU:\s(\w+-\d+)/ This will match one or more "word" characters followed by a hyphen followed by one or more numbers. An even more restrictive approach could be this: /SKU:\s([A-Z]{2}-\d{6})/ This matches for 2 uppercase letters followed by a hyphen followed by 6 numbers
-
okay but you also mentioned html, css, etc.. so is it also supposed to show line by line those things too? Also, I asked that you show me exactly what you want to see. The point of this exercise is that you aren't being very clear, and it's not just the language barrier that's making you unclear. Pretend you have already made the script that does what you want. Take the code I have given and generate the log file and output. You will have to do this manually or by hand of course, since you don't actually have the script yet. Then post it, so that we have a very clear "before" and "after" picture.
-
Okay so how exact do you want this? Let's say you have the following: <html> <head> <script type='text/javascript' src='someScript.js' /></script> </head> <body> <?php include('db/connect.php'); $query = 'select param, value from table'; $result = $mysqli->query($query); ?> <script type='text/javascript'> var config = {}; <?php if ($result) { while ($row = $result->fetch_row()) { echo "config.{$row[0]} = '{$row[1]}';"; } } ?> runScript(config); </script> </body> </html> Show me exactly what you expect to see in the log file from this.
-
Yep, there will be no perfect solution with regex alone. Even if the grammar and punctuation are done perfectly, there are too many alternates and exceptions that involve punctuation, nested stuff, etc. And that's if the grammar and punctuation are perfect - very few people out there are 100% accurate about that stuff, or even 75%. Even if you were to attempt to make a parser that uses more than just regex, it's just not possible to perfectly parse all the exceptions and overcome the fuckups. The human brain is considered an amazing thing for a reason: because it can manage to parse it.
-
Right, but in this condition block: if(!$file) { //file doesn't exist RefreshStatus(); $fgame = $data[1]; $flogin = $data[2]; }else Yes, you create the file, but this code block doesn't assign anything to $data so you're trying to reference $data[1] and $data[2] when they don't exist.
-
you aren't assigning a value to $data unless the file already exists. IOW $data doesn't exist unless the file exists, but you try to reference it when the file doesn't exist.
-
so where is this "session c=#" normally found when you go to it in your browser? Is it in the response url? on the page somewhere in a div tag or something?
-
<? ?> isn't short tag. <?= ?> is short tag. But if you changed them to <?php ?> and you still get that error, check for missing closing bracket in this file: require_once("include/forum_id.php");
-
Timed events -- Not sure best way to approach this
.josh replied to RyanWalsh3387's topic in PHP Coding Help
but to answer your question, you'd use a cronjob to run a script every minute or hour or whatever and check the current timestamp(s) in the database vs. current time. -
Timed events -- Not sure best way to approach this
.josh replied to RyanWalsh3387's topic in PHP Coding Help
what kind of system is this for? I can't imagine a whole lot of scenarios where time-based assertions are feasible from a "business" PoV.. -
considering there's login involved, you probably need to handle cookies. Look at the various cookie settings in curl_setopt
-
well that's client-side code so "root" means the root public dir that browsers can access. So for example if the page that code is on is http://www.yoursite.com/path/to/page.php and you did this: <video poster="../videos/1.jpg" preload="auto" controls> <source src="../videos/placeholder.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' /> </video> the browser would attempt to look for them at http://www.yoursite.com/path/videos/1.jpg and http://www.yoursite.com/path/videos/placeholder.mp4.jpg But, if your page is on http://www.yoursite.com/page.php (the public root), and you prefix with "../" then it will still resolve to the root public dir, so doing "../videos/1.jpg" would be the same as http://www.yoursite.com/videos/1.jpg So basically the page that code is on must not be in the public root; it must have been http://www.yoursite.com/path/to/whatever/page.php and you expected your files to be located at http://www.yoursite.com/path/to/whatever/videos/1.jpg but it resolved to http://www.yoursite.com/path/to/videos/1.jpgso the "../" was indeed messing things up.
-
I suppose this sounds like what you want to do? <form action='' method='post'> <input type='text' name='av[]' /><br/> <input type='text' name='av[]' /><br/> <input type='text' name='av[]' /><br/> <input type='text' name='av[]' /><br/> <input type='text' name='av[]' /><br/> <input type='submit' name='operation' value='array_sum' /> <input type='submit' name='operation' value='count' /> <input type='submit' name='operation' value='end' /> </form> <?php if ($_POST) { $array = array_filter($_POST['av']); // filter out empty values $func = $_POST['operation']; if ( function_exists($func) ) echo call_user_func($func,&$array); } ?>
-
the path should either be the absolute path on the server, or else a path relative to the script being executed. "../" means "start where the script is being executed and go up one dir level". So based on the path in the OP, that file should be located at: /full/server/path/script.php <-- the script that is running /full/server/php/info_test.txt <-- this is where the file should be, based on the path given what the actual server path is ("/full/server/path/") depends on how the server and file structure is setup. If you are on shared hosting then you likely do not have full root access and as far as your script is concerned, the root dir starts at your account's directory, which is usually the public html directory (usually named htdocs or public or public_html or similar) or one dir level above that. But regardless it will still look for it starting from there. Anyways, point is, the important thing is where it is located relative to the script that is running.
-
I DON'T C WUT U DID THAR
-
wait..you CAN'T see white text on a white background????!!?! This is ridiculous, someone needs to do something about that.