ManiacDan
Staff Alumni-
Posts
2,604 -
Joined
-
Last visited
-
Days Won
10
Everything posted by ManiacDan
-
It's 1 in 9. Basic statistics have nothing to do with PHP. Also, this code has an exit() call BEFORE the mysql_query, that query will never run. There's also a random closing curly brace.
-
It shows errors? Show us the errors. Is this SQL Server or MySQL server?
-
First iteration of foreach much slower than rest
ManiacDan replied to lonewolf217's topic in PHP Coding Help
It says no such thing, and you have been proven wrong three times now. I'm closing this thread so your misinformation doesn't continue to pop up to the top of the forum. You are wrong, both kicken and I have demonstrated that. I know English isn't your first language, so trust me when I tell you that you are misinterpreting the manual. Thread closed. -
First iteration of foreach much slower than rest
ManiacDan replied to lonewolf217's topic in PHP Coding Help
The copied array is only used internally by PHP. Maybe that's where the misunderstanding is coming from. You try to loop over $arr. PHP creates $arr_copy, and uses that internally to control the loop. You cannot access the copied array. This is not like a function call, it's a behind the scenes copy. It's not a local or lexical copy, it's a control copy, used by the language and not by you. The post I put above proves that SOMETHING stops the array from going into an infinite loop. How would PHP know the original length of the array without a starting-point copy? You can also create large memory-intensive arrays (like object trees) and use memory_get_usage to see the large spike in memory when you start a foreach. Your second example has nothing to do with the topic. Values created inside of a foreach are still in scope when the loop exits. That's just how PHP's scope works, it's not broken by loops. If you continue to tell me I'd better understand the topic you're clearly not understanding, you're going to continue to look foolish. Stop with the personal insults and address the topic. What rules? What "rule of arrays" did I break in my article? You do understand that some of the demonstrations in my article were made to show exactly the behavior I've been describing right? -
These session errors have nothing to do with your database issues. Did you change your password?
-
First iteration of foreach much slower than rest
ManiacDan replied to lonewolf217's topic in PHP Coding Help
You are still misunderstanding those sentences. An internal copy of the array is absolutely made prior to the foreach. Look: php > $arr = array('a', 'b', 'c'); php > foreach ( $arr as $letter ) { php { $arr[] = strtoupper($letter); php { } php > print_r($arr); Array ( [0] => a [1] => b [2] => c [3] => A [4] => B [5] => C ) Now if, as you said, no copy was made of the ENTIRE array, then as I added items to the end of the array within the loop, that would continually increase the size of the array. If, as you think, no copy of the whole array is made, then when the pointer got to element 3, it would see 'A', and add 'A' in as element 6 and on and on forever. However, as I've said twice now (and wrote a well-researched article about with examples you could have tried), when a foreach loop is started on an array with a refcount of 1 (no references to it other than the variable name in use), a complete copy of that array is created and used as the control for the loop. modifications to what looks like the original array will have no effect on the operation of the loop. In addition to that, the quotes from the manual ALSO apply. If you modify the array pointer inside the loop, the loop will malfunction in unpredictable ways. Now, if you still don't believe me even after reading the proof in my article and the proof I just pasted above, there's not much hope for you. Both my article and the PHP manual are correct, they're talking about different things. -
First iteration of foreach much slower than rest
ManiacDan replied to lonewolf217's topic in PHP Coding Help
You are wrong. Read it http://ru2.php.net/manual/en/control-structures.foreach.php Pay attention on "When foreach first starts executing, the internal array pointer is automatically reset to the first element of the array." and other words. Foreach is iterating through an original array, it just change an internal pointer (current position) of that array. Try again. Foreach makes a copy of an array. I demonstrated that in the article I wrote. The quote you're using demonstrates that calling foreach will always start at the first element. It has nothing to do with copies. -
First iteration of foreach much slower than rest
ManiacDan replied to lonewolf217's topic in PHP Coding Help
Is $resultDisk an array or an object that implements arrayAccess? That's a completely different thing. if it's an object, there's nothing you can do really. -
First iteration of foreach much slower than rest
ManiacDan replied to lonewolf217's topic in PHP Coding Help
You may have read about it in my article on it here. There are some tricks in that article (like assigning a fake reference to the variable) to cut down on the copy size and memory usage. -Dan -
There isn't much more to say to this, I already gave the whole list. If you don't think "is port 80 responding" is enough of an indication of "up," then...go down the list. When I wrote the monitoring for softlayer, those were the levels we offered: Ping, tcp connection, tcp response, parsed string response. (plus a lot more for non-web servers, but that's the web stack)
-
But if the web service returns a 503 with every request, is that "working?" That's the question. What constitutes a "working" website? If you just want to know if the server is turned on, use ping. If you just want to know if apache is running, use curl with no check. If you just want to know if PHP is working, use curl with preg to pull specific items off a known good page. If you just want to know if the whole end-to-end website is working, perform activity on the site (creating content, changing menu options) and check their results with multiple sequential calls from cURL or some other page-fetching tech. -Dan
-
As you've discovered, the developer needs to manually add that information to their site in order for people to know it. You cannot get the active connection count for another server without their developers specifically allowing for it. Also, please try to write good questions and good thread titles. You posted a thread called "PHP CODING HELP" into a forum called "PHP Coding Help"
-
Ping only tells you if there's a working OS at the other end of the line. cURL only tells you if the web server is serving SOMETHING, not necessarily the page itself. You need to combine curl with grep (or preg or whatever) and ensure that the page CONTENTS are coming through. If I wanted to check if PHPF were up, I would check for the phrase "Page Created In" because that only shows up in the footer and only on successful page load.
-
As much as I hate the phrase RTFM, go do it.
-
Look into regular expressions or the DOM object. You will probably have to write a separate spider for each site unless you're very talented.
-
And what country will you be in? What country will your clients be in? What country will the server be in? Will you be paying cash for these play credits? Is it a standard game of chance or is it a game of skill? You should ask a lawyer these questions, since it's very complicated (as you can see)
-
Problem with white spaces on image file upload?
ManiacDan replied to simmsy's topic in PHP Coding Help
It's not stripping anything, tag attributes must be quoted. "<div id='profileimage'><img src=\"".$image."\" width='200px' height='200px'></div> " -
Problem with white spaces on image file upload?
ManiacDan replied to simmsy's topic in PHP Coding Help
Perhaps you don't understand what we're asking. The code you're showing us is used to move the uploaded file to a permanent storage location. You need to show us code that includes an <img> tag, that's the code that displays the image. -
Sessions are stored using cookies, and the cookie depends on the subdomain. You'll have to use session_set_cookie_params to force your subdomain to cookie for the whole site.
-
We can't see your screen, we don't see any spaces in any of your variables.
-
Are you sure the address is correct? Have you printed it out and copy/pasted it into a browser?
-
You can't redirect a customer to one URL but show them a page from a different URL. The URL is the address of the page you're viewing. You can use mod-rewrite to change one URL to a different file.
-
Don't use header redirects then. Have the under contructions page be a template or a PHP include. At the very top of your index, check to see if the site is in maintenance. If it is, include the maintenance template and die.
-
Problem with white spaces on image file upload?
ManiacDan replied to simmsy's topic in PHP Coding Help
That's the same code you already showed us, and it's not (1) getting image name to display, or (2) displaying the image -
Then I'm not understanding the problem. Your code says "if they came from post_new, send them to post_new. If they came from logged_in, send them to logged_in."