Jump to content

phporcaffeine

Members
  • Posts

    361
  • Joined

  • Last visited

    Never

Everything posted by phporcaffeine

  1. Okay, I am using the floatval() and putting the result as the key in the stack. Then I sort the stack with sort() and I get close but no cigar: <net>-0.04</net> <net>-0.05</net> <net>-0.05</net> <net>-0.05</net> <net>-0.05</net> <net>-0.06</net> <net>1.54</net> <net>-0.05</net> <net>-0.06</net> <net>-0.07</net> <net>-0.07</net> <net>-0.07</net> <net>-0.08</net> <net>-0.0905</net> <net>-0.09</net> <net>-0.09</net> <net>-0.09</net> <net>-0.11</net> <net>-0.11</net> <net>1.02</net> <net>-0.15</net> <net>-0.17</net> <net>-0.17</net> <net>-0.21</net> The goal is to sort the stack highest to lowest using the key to sort with.
  2. I have an XML file that has nodes in it like this: <net>-1.0112</net> <net>1.54</net> <net>-0.0112</net> ... etc Now I am parsing them into a stack (which works fine) .... what I want to do is sort that stack, highest to lowest. The issue I have is that php doesn't seem to sort the numbers correctly. it sees -1.0112 as a higher number than 1.54 ... how do I do this? Thanks in advance
  3. I have an XML file with 800,000 nodes. I have a script that loads, reads and parses the file (it places all the XML node into a stack) however 800,000 nodes is to much and it causes PHP to hit a memory limit. I have bumped up mem_limimt all the way to 700M but no luck. Is there a max to the size of a stack and if so does anyone have a way around this? The goal is to load all nodes and then apply a simple sort() function. Thanks in advance.
  4. Okay, I have a list of various ip address that are not in any particular order or form any particular subnet ... think of them as just random addresses. Here is a sample: 193.122.140.196 193.122.140.192 212.209.042.128 193.132.159.000 203.166.028.064 156.070.222.001 218.104.051.160 194.034.064.001 194.034.065.001 194.034.066.001 194.034.067.001 199.068.016.000 067.111.075.099 212.044.025.206 212.044.008.034 195.102.024.074 193.122.140.207 212.209.042.135 193.132.159.255 203.166.028.127 156.070.222.255 218.104.051.174 Now I need to iterate over this list "somehow" to identify and group together, like addresses so I can express them by ranges. For example: 193.122.140.207 and 193.122.159.255 would be expressed as 193.122.*.* 193.122.140.20 and 193.122.140.80 would be expressed as 193.122.140.20-80 I don't seem to be able to figure out how I would logically do it? Any help or ideas? Thanks in advance
  5. The query does in-fact work, it just returns all rows instead of respecting the limit clause. My only other solution I guess is a staged query
  6. QUERY: mysql_query(SELECT ad_meta.*, tracking.views, tracking.clicks FROM ad_meta, tracking WHERE tracking.better_id = ad_meta.better_id AND ad_meta.better_id='" . $temp[0] . "' LIMIT 200"); Now the query does select by the criteria I want it to but it seems to ignore the LIMIT clause and returns many more rows than the 200 threshold I want. Please tell me what I am doing wrong? -TIA
  7. the page that the iframe targets is by all rights, a seperate and unique page and therefore doesn't access the same namespace as the parent. In your iframe tag, when you target the framed page, target it with $_GET args .... thats the only way. Depending on how your site works, this might not work for you.
  8. Trying to find something written in PHP that would do a google style "did you mean". I could just screen scrap from Google but then I would have to give them some sort of 'powered by' credit and I'd rather not. I would like to 'in-house' it. Anyone know of anything? -TIA
  9. I am starting an informational site for losing weight and getting a flat stomach. I don't have all the content and links completed but the structure and design of the site are complete. I would like to know how I could improve and what I should improve. http://www.washboardtummy.com -TIA
  10. I'm trying my hand at making an internet content filter and making the proxy from php. Basically, the browser is told to look at xxx.xxx.xxx.xxx as the proxy, that ip address is a machine running php. Now php catches the request and does whatever I want it to to determin if the request is allowed. If its allowed it should return the original request. It is sort of working .... anything on the root of the requested domain is displayed but when the documents on the root make references elsewhere, it bombs. If anyone has any clues, ideas or if there is a pre-built that someone knows of I'd be grateful! so far .... <?php $url = $_SERVER['HTTP_HOST']; $parts = parse_url($url); $test = substr($url, 0, 4); if (strtolower($test) != "http") { $url = "http://" . $url; } echo $url; $doc = file_get_contents($url . $parts['query']); echo $doc; die(); ?> -TIA
  11. jber, The reason MadTechie suggested .csv is because its text based and marker deliminated. PHP has two methods called explode() and implode() that would work perfectly for such an application. Quick example for reading a comma deliminated .csv file: <?php //INIT VARS FOR USE LATER $hold = array(); $cnt = 0; //YOU CAN ALSO USE $fileResource = file('path/to/csv'); //BUT IT DEPENDS ON HOW YOUR .CSV IS STRUCTURED BECAUSE file() RETURNS AN ARRAY VS. STRING $fileResource = file_get_contents('path/to/csv'); //THIS WILL TURN $hold INTO AN ARRAY WHO'S VALUES COME FROM $fileResource, SEPARATED BY THE DELIMINATED MARKER (COMMA) $hold = explode(',', $fileResource); foreach ($hold as $value) { $cnt++; echo $cnt . ".) " . $value . "<br />"; } ?>
  12. If you'd like to do it in a factored way: replace this: $host="*************"; // Host name $username="***********r"; // Mysql username $password="*********"; // Mysql password $db_name="***********"; // Database name with this: mysql_select_db("************", mysql_connect("**********.*******.net", "***********", "************"));
  13. I realize the default browser action is to load .js and .css content prior to reading the body of the document. I'm actually looking to display a progress bar or some sort of indicator while they are loading (because the site loads a lot and it's as condensed as it can be already).
  14. I am looking for a technique to preload .js and .css files, not just images. Any ideas? -TIA
  15. Hi, I am using PHP to execute an external program using system(). Using system() though I found that PHP will remain in memory until the external program ends. Is there a way to call an external program with PHP and have PHP exit before the external program exits?
  16. If its a localhost URL and you see PHP code it's because the PHP interpreter engine is not parsing the code. However, that is not the correct or default action that should occur. If the PHP Interpreter engine is not running on the localhost machine and you try to view a PHP script in a browser (on the localhost machine), the browser should attempt a file download, which is the default action for any mime type the browser does not have an association for. If however PHP is displayed as code in the browser, I would think that the PHP file type extension is probably set to open with the browser on the localhost machine. If were talking about an HTTP web site (non-localhost) and you are able to view the PHP code of script on a web site then it could be something as simple as the author of the script using show_source();
  17. Okay, I'll google up on cURL BTW: Using PHP in CLI means I wouldn't have a browser, which means no HTML which means no FORM to POST with ... etc Thanks
  18. Wouldn't I need a script on the server to accept the $FILES[] post from the CLI script? See I'm trying to avoid user interaction. I guess I could 'forge' a form submit with JavaScript but I don't know if echo'ed JS will work in CLI?
  19. Interesting project here: I'm using PHP (CLI) on a client machine, and I need a script on the client (executed via CLI) to transfer/upload a file to a web server using HTTPS (I could use HTTP if I have to). The catch is, I can't use FTP methods (firewall/port issues) ... but I have complete control over the client machine as well as the server machine. I can however use the following ports; 8080, 443 & 3306. I realize that of the three ports I can use, 8080 would be the best but still not suited for mass data blocks. I think 8080 will be okay because I am transferring files that are less than 5k. Anywho, I thought I could get away with fopen() but I'm reading in the manual that the HTTP & HTTPS wrappers are 'read-only' which isn't going to work (because I am trying to write a file to the server, not read one). So as I research further I am think that somehow 'sockets' might do the trick. I have a very basic understanding of sockets & php but I would like to know if I could do what I am trying to do using sockets? -TIA
  20. The original poster said that the escape is there and that the forum wasn't letting it show up ... "Thanks in advance! For some reason the code block is ignoring the very first backslash. It's there, just not showing up." (its at the very bottom of the first post)
  21. For debugging purposes, flip 'DISPLAY_ERRORS' on change ' .... $result = mysql_query($query); ..... ' to ' .... $result = mysql_query($query) OR die(mysql_error()); ....' change '..... $class = "{$row['class']"; ....' to '.... $class = "$row['class']"; ....' (this declaration wouldn't be valid because it is missing the closing "}" brace) Also, remove all the curly braces " { } " from your variable declarations (starting right below //DEFINE VARIABLES)
  22. PHP 5.2.3 Apache 2.2.4 Win XP - Vista I'm not using PHP in a web fashion in this project, I am using the CLI to gather information about the computer that the script is on. I've already created a class that gets useful information about the computer like; Computer Name Computer LAN IP Address Computer EXTERNAL IP Address Reverse Public DNS Entry for the EXTERNAL IP Address ISP Name ISP Address ISP Phone ISP Email Some of these items I get by parsing the result of a command line utility ... etc I want to get some other information like CPU type/speed, RAM size ... ect ... core system stats. Does anyone know of a way to get stats like that with PHP CLI? Maybe I could parse more results from a command line utility but which one? -TIA
  23. Try this: var_dump($row); That will at least show you all the columns that mysql_fetch_array() is returning into your stack(array). Once you do that, then you can see how you need to reference your stack (i.e $row['stack_element']). If the stack is missing element that you think should be there then look at your query statement and make sure its asking the database what you think its asking.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.