HaLo2FrEeEk
Members-
Posts
724 -
Joined
-
Last visited
Never
About HaLo2FrEeEk
- Birthday 08/17/1989
Contact Methods
-
Website URL
http://infectionist.com
Profile Information
-
Gender
Male
HaLo2FrEeEk's Achievements
Advanced Member (4/5)
0
Reputation
-
The URL does work in a browser, you just have to provide a username for an online user. If the user is not currently online, the return will simply be: [ ] if the usr doesn't exist, or no name is provided, then you'll get an error page with an "HTTP Status 409" message. Try going here: http://www.stickam.com/servlet/ajax/sessionMembers?sessionType=live And getting a username from the list, it'll be the first value in each of the arrays. Put that username after the URL: http://www.stickam.com/servlet/ajax/getLiveUser?uname= And it should work. Like I said, I can do it just fine using the same script on my local computer's Apache server. I literally wrote the script on my local server, got it working, then saved the same script to my FTP and tried to load it. Is there some way to create a stream context using an exact copy of the header data that the browser requesting the page used? Come to think of it, is there actually any way to view the header data that my browser sent?
-
I'm writing a quick little script to grab some information from Stickam.com, specifically using the "API" they have set up to get a user id from a provided username, and a username from a provided userid. These are both publically accessible pieces of information, so I'm not getting into anything I shouldn't, I'm just using the publically accessible API instead of scraping the HTML. For some reason I can't explain though, I can't seem to get the contents of the page using PHP. Here's my code: $username = @$_GET['username']; if(!$username) { die("no username"); } $url = "http://www.stickam.com/servlet/ajax/getLiveUser?uname=".$username; $html = file_get_contents($url, false, $context); echo "<pre>"; echo $html; echo "</pre>"; But everytime I load this page on my server, I get this response: Warning: file_get_contents(http://www.stickam.com/servlet/ajax/getLiveUser?uname=[username]) [function.file-get-contents]: failed to open stream: Connection timed out in [file] on line 7 I can load it just fine on my Apache server running on my personal computer, and in my browser (both IE9 and Firefox), but not on my website. I've tried mimicking the headers that my browser sends and creating a stream context to send with the file_get_contents() call, but so far nothing seems to work. Any ideas?
-
Wow, it's like my very long, very descriptive post detailing examples of use and english translations for each type of loop (except do-while,) just doesn't exist. Sure am glad I took all that time to write it all up.
-
If you plan to display all these sub categories on a single page (unlike Google, which only displays two or three subcategories for each main category,) then you'll need to look into recursive functions. Basically the code runs over and over as deep as the tree goes until it hits an end, hen it goes back up to the next and prints the next sub-sub-sub whatever category. If you're looking to make it exactly like Google, where only a few sub categories are shown for each main category, then as you click a main category all the sub categories are shown (I'm getting really tired of typing the word category,) that'll be a lot simpler. You'll basically just pass the current category's name (or ID) to the script, which will look up all sub categories (or whatever is at the bottom, if there are no sub categories,) and print them to the page. All you'll need to define in the database is each sub category's parent category. Here's a very simple example: http://infectionist.com/tutorials/ This is a page on my own site that lists the different tutorial categories that I have available. Click on one of these main categories and you'll be presented with a page that lists each individual tutorial for that category. Seriously, tired of typing that word!
-
That's not how things work here at PHP Freaks. We're not here to give you the answers, or do the work for you, or give you intricate details on how to do something. We're here to help YOU find the answers, to point you in the right direction. Give a man a fish he eats for a day, teach him to fish and he eats for the rest of his life. Now, I'm assuming you're using a Windows server, since you mentioned you have Windows 7. Unfortunately I would only know how to help you if it were a linux server, in which case the answer would be CRON. As far as Windows servers go, though, I don't know how to schedule a php script to execute.
-
I've always thought of for loops as more defined while loops. Here is an example: for($i = 1; $i <= 10; $i++) { echo "This is line " . $i . "<br>\n"; } In plain English, here is what's happening: The variable $i is defined with a value of 1 The loop is set to run while the value of $i is less than or equal to 10 (so it'll run 10 times) The loop is instructed to increase the value of $i after each iteration (each time it runs the loop) The code executes, printing 10 lines reading "This is line 1"..."This is line 10" The loop exits. The same can be done with a while loop: $i = 1; while($i <= 10) { echo "This is line " . $i . "<br>\n"; $i++; } Almost the exact same thing is happening here, only in a different order: $i is defined with a value of 1 The loop is instructed to continue running, as long as the value of $i is less than or equal to 10 (so it'll run 10 times) The first line executes, printing the line "This is line 1" The second line executes, increasing the value of $i to 2 The loop checks that the value of $i is still less than or equal to 10, if it is, it prints the next line The loop continues until the line "This is line 10" prints The value of $i is increased to 11 The loop exits since the value of $i (11) is now greater than 10. Foreach loops are probably my favorite type of loop. They're great for working with arrays: $array = array("Hello" => "World"); foreach($array as $key => $value) { echo "The item with key \"" . $key . "\" has a value of \"" . $value . "\".<br>\n"; } They're also very simple to explain: For each item in the array $array, define $key as that item's key, and define $value as that item's value (ex. ["Hello"] = "World") Using the above example, I would get a line that looked like this: The item with key "Hello" has a value of "World". The loop continues until all items in the array have been processed. Once you understand them, loops are actually quite easy to work with and they REALLY come in handy. If you have any more questions please feel free to let me know and I'll do my best to help you out.
-
SQL table query result not passing to POST string
HaLo2FrEeEk replied to twittoris's topic in PHP Coding Help
I can think of a few reasons you might be having an issue. If you solved this already then great, but I'd still like to put in my $0.02 (two cents.) First, unless you're just not posting it, I don't see an end to your while loop. You're missing the closing } Next, you're using mysql_fetch_array, which returns a numerically-indexed array, not an associative array, yet you're trying to get the value from the result using $row['name'], you should change mysql_fetch_array() to mysql_fetch_assoc(). And finally, $row is an array, not a string, so when echoing it you're only going to get this: Array() What you should do is something like this: $query = mysql_query("SELECT * FROM $tbl_name") or die(mysql_error()); while($row = mysql_fetch_assoc($query)) { echo = "p_doctor_name=" . $row['name'] . "&p_name_type=A&p_search_type=BEGINS"; echo "<br>\n"; } This will print the POST info that you want. Alternatively, if you want to use the POST info later in the script, you could change the first echo line in the loop, to this: $postinfo[] = "p_doctor_name=" . $row['name'] . "&p_name_type=A&p_search_type=BEGINS"; And remove the echo "<br>\n"; line. That will create an array containing each of the lines, which you can then iterate through in a foreach loop. -
You call for a variable named $refid in your query, yet this variable doesn't exist before the query is executed, thus the variable's value will be empty, making your query look like this: SELECT * FROM reference.users WHERE reference.user_name = users.user_name AND reference.refid = '' I would also recommend that you capitilize the keywords in your query, like SELECT, FROM, WHERE, and AND. If makes t easier to read. Anyway, so right now you're selecting everything from the reference.users table where reference.user_name is equal to users.user_name and where the reference.refid is empty. Unless I'm missing something. I think the problem is here: WHERE reference.user_name = users.user_name You're telling it to select everything from the reference users table where the names are the same, which you said they were. You collect the POST variable user_name, why not use that in your query? $user_name = $_POST['user_name']; $refid = $_POST['refid']; $query = "SELECT * FROM reference.users WHERE reference.user_name = '".$user_name."' AND reference.refid = '".$refid."'"; Without more background into what exactly you're doing (I'm having difficulties understanding your description,) I can't help much more.
-
Or perhaps if someone gave you a link you should click it and read it and learn. Hmmmm... I understand that, yes, you can learn from reading the code, but only if you actually understand what is being done. Why don't you try it yourself. Here's an assignment: Write a script that will delete all files in a single folder, but not the actual folder itself.
-
Next time try googling. And don't expect anyone to write you code, that's way presumptious...especially when you're asking people to write code to delete all files on a server. The whole point of this forum is to learn.
-
I'm trying to create a QRCode decoder in PHP. I'm not sure if something like this has been created already, but from my searching, I don't think it has. If you don't know what QRCodes are, they're basically 2D barcodes that let you store a lot of information. Here's an example: (mouse over for the whole thing) This code is simple, just contains the text "0123456789", but it's just for testing purposes. I'm basically working my way up a QRCode generator script, doing everything in reverse. it's obviously possible to decode them, there are many barcode readers for mobile phones capable of doing it, and there's also this site: http://zxing.org/w/decode.jspx But the source for that web-based decoder isn't available, and I'd like to try and figure it out on my own. Ok, so now that you know the context, here's what I'm doing. First, I read the image and get it's width and height, which should always be equal. I start at the top-left corner and work my way down 1 pixel at a time in a diagonal line until I find a pixel of a different color (the border is always white, but not always the same width.) Once I've found a different colored pixel, I know how wide my border is. Starting at the border offset, I again recurse down until I hit another white pixel, this gives me my block width (the width and height of each square in the image.) I then find the "smallsize" of the image, the size I have to make it so that each square is a single pixel, without the border. I then do an imagecopyresized() to shrink the image down to it's smallest size, making each square a single pixel. And this is where I'm stuck. I need to read the value of each of the pixels, BUT, I need to ignore some as well. The larger squares in the top-left and right, and bottom-left are positioning data, used to tell mobile scanners how to rotate the image to read it. I don't need their pixel data. Each of the positioning squares are 8x8. There are also lines of timing data. I'm not sure what it's for, but it's not part of the data and I don't need it's pixel value either. Here's another version of that same image above, but with the data pixels turned red: The 3 8x8 squares in the corners and the black pixels apart from those need to be ignored. Basically what I'm doing now is I'm just iterating through every pixel, like this: $x = 0; while($x < $smallsize) { // while x is less than 21 $y = 0; while($y < $smallsize) { // while y is less than 21 $vals[$x][$y] = imagecolorat($shrink, $x, $y); $y++; } $x++; } And that gives me an array or each pixel's on/off value. So since Idon't need the positioning and timing pixels, how would I go about ignoring them?
-
Fixing a div with children to the bottom of the window
HaLo2FrEeEk replied to HaLo2FrEeEk's topic in CSS Help
You know what it was, something completely stupid. DOCTYPE! When I'm testing scripts like this I usually don't make them fully HTML compliant, after all I'm just testing a concept. When I put them into the working environment I abviously put them into compliant pages. Well, apparently using the position: fixed attribute requires that a strict or XHTML doctype be set. Adding that single line in fixed everything right up. I now have a working PHP progress bar: http://halo3shots.infectionist.com/progress.php -
I'm trying to make a div position itself at the bottom of the window, fixed location so that regardless of my scroll position it always stays at the bottom, and inside it has layered children divs. Basically I've got a wrapper div, and inside I've got 2 child divs. One of the child divs displays completion percentage text, the other a progress bar. I want the text div to be on top of the progress bar div, and all of it to be inside the wrapper div, at the bottom of the window. Here is my HTML and CSS: CSS <style> body { margin: 0px; } #progress_wrapper { position: fixed; bottom: 0px; margin: 0px auto; width: 100%; height: 20px; background-color: gray; z-index: 0; } #progress { position: absolute; bottom: 0px; left: 0px; height: 100%; border-right: 1px solid black; background-color: #0f81a7; z-index: 50; } #progress_text { position: absolute; bottom: 0px; left: 0px; width: 100%; height: 100%; color: #FAFAFA; text-align: center; z-index: 100; } </style> HTML <div id="progress_wrapper"> <div id="progress_text">Loading...</div> <div id="progress" style="width: 0%;"></div> </div> This should work, but what I get instead is the wrapper div positioned at the top of the window and the text and progress bar positioned at the bottom, layered properly, and it still won't stay fixed, both the wrapper at the top and the progress and text bars at the bottom scroll with the window, I need their position to be fixed at the bottom. There has to be a way to make this work! Please, I tried asking at another forum and the question got completely ignored. This is a brick wall in my development and I can't get any further without figuring this out, please someone help me!
-
Yeah uhm...I'm gonna let his reply speak for me.
-
Ok, so I found out that if I output more than 64kb to the browser, it'll get sent, so basically all I have to do is output 64kb+ every iteration of my loop. Since that's not feasible, and since I know it's not a browser issue, I've written my host's tech support and they're working with me on the problem. The reason I know it's not a browser thing is because it does the same thing in both Internet Explorer and Firefox. It does this whether I have output buffering on or off and whether I ob_flush() and flush() or not.