Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. The server problem is that you ftp_connect() fails for the site you want to connect to, but succeeds for a public server? Are both using the default ftp port number?
  2. That's not very professional of them. Is your database name stored in your code somewhere?
  3. This works fine for me: <? $filename = "/pub/adware/win9x/ukphone2.txt"; // Connect and login to ftp server $Connection = ftp_connect('194.159.255.135') or die("Could not connect!"); ftp_login($Connection,"ftp","me@here.com"); // Get time file was last modified $UNIXtime = ftp_mdtm($Connection, $filename); // Convert to human readable time if ($UNIXtime != -1) { $FILEtime = date("Y:m:d", $UNIXtime); print "Modification time: $FILEtime\n"; } else echo "Error!"; // Close ftp connection ftp_close($Connection); ?>
  4. Where does it fail? Try printing out all the urls it matches and comparing that to the original page source. If it's finding the urls but misinterpreting, you can print out what your script thinks the urls should be and see which ones are wrong. You might want to print out the widths and heights too just to confirm there's not something going wrong there (for example, the website might check the referrer and that might not be set correctly).
  5. If that's the case, try this: print <<<EOD {$_POST[$BlockName . '_' . $FColor]} EOD;
  6. Can you give an example of a site it doesn't work for? That's the simplest approach. Then we have something concrete to work on. Situations I imagine might cause problems are 1. Multiple img tags on one line 2. img tag split over 2 lines 3. base href set for html page (modifying where image paths are relative to) Edit: The most reliable way is to use an HTML parser
  7. Try removing this line from array_processing.php: echo "<form>"; Forms can't nest, so that will probably take priority over any later form tags.
  8. You can try {$_POST[$BlockName.$Title]} Those {} will allow you to do a lot of stuff that otherwise wouldn't work inside a string or "EOD" block (the technical but still rather odd name for an EOD block is "heredoc").
  9. Here's a standard database style structure Table "items" Column 1: Integer identifier "item_id" Column 2: Text item name "item_name" Column 3: Enum item type "item_type" Column 4: Integer item value "item_value" (or could be floating point) You might want to add additional item attributes to that table like damage, charges, wearable locations, and so on. Table "stores" Column 1: Integer identifier "store_id" Column 2: Text store name "store_name" And additional store attributes in that table, but NOT the items .. Table "store_inventory" Column 1: Integer identifier "store_id" Column 2: Integer identifier "item_id" Column 3: Integer item count "inventory_count" This table has one row for each item that a store has in stock. Does that makes sense? An item's identifying characteristics go in the "items" table. A store's identifying characteristics go in the "stores" table. Then a third table links stores and items to provide inventory information.
  10. Is graphics under public_html? If so you can try like this: include("../included.php");
  11. <?php $username = clean($_POST['username']); $password = clean($_POST['password']); $conn = mysql_connect("localhost","root","root"); $db = mysql_select_db("sam"); $checkuser = "SELECT * FROM users WHERE username = '$username' AND password = '$password'"; $checkuserlog = mysql_query($checkuser); $num_results = mysql_num_rows($checkuserlog); if($num_results == 0) { echo 'wrong username or password'; } else{ echo ' logged in! '; } function clean($str) {return mysql_escape_string($str);} ?> You can try this code. It will not tell you which of username and password is wrong though. There are 2 problems in your original code: 1. You check username and password, but not username and password together. If user A has password X and user B has password Y, then you can login with username A and password Y, even though they are not for the same user! 2. You need to use mysql_fetch_row() after a query to get the actual data.
  12. Here's an example of how to fix it (for the first error only): if(isset($_POST['fullname'])) { $query="SELECT client_id, first_name, last_name, company_name FROM $dbname.clients"; $result=mysql_query($query) or die($query . '<br >'.mysql_error()); while($row=mysql_fetch_array($result)) { if(!isset($row['company_name'])) { //echo "$row[last_name], $row[first_name] ($row[client_id])<br>"; line 98-> $query="UPDATE $dbname.clients SET full_name='{$row['last_name']}, {$row['first_name']} ({$row['client_id']})'"; $update_result = mysql_query($query) or die($query . '<br >'.mysql_error()); It's important that you use a different result variable inside the loop, otherwise you will overwrite the $result being used in the while(). The query also may not be correct yet, all I've fixed is the PHP syntax.
  13. With date(), you can get the day of year using "z" and the year itself using "Y". You can generate the volume and issue numbers from those.
  14. If you need the javascript time it's a bit more complicated. The problem is that javascript only runs after the php script is finished. So you need to run a second php script which receives the time back from javascript. Or you can ask the user to set their timezone, OR you can try to auto-detect the timezone based on things such as IP address. What I wrote only works with server time (though once you have the user's time you can use it in a similar way). Anyway, there's 2 options I can think of 1. Use ajax to send back the time from the user 2. Submit the time from javascript via a form The second is probably easier
  15. You mention "the user's time" and "the local machine's time". The time for your php script (the server's time) won't always match the time for javascript (user's time). That aside, if you want to move the end of the day to 10 pm instead of 12 midnight, you could try adding 2 hours to the time. I don't know how that will interact with daylight savings but it should work most of the time. print date("D H:i:s\n", strtotime("+2 hours")); Then all you need to check is the day name.
  16. This looks like what you are looking for: apache_request_headers() Assuming you are using apache.
  17. btherl

    order

    Have you used arrays before? It can also be done purely in SQL using group by, I think. The strange variable names you've used have confused me though, so I'm not entirely sure what you are adding up.
  18. You can use these to generate your own error messages including script and line. Often a backtrace is more useful.
  19. btherl

    Game

    Hmm.. do you have any code yet? Having something to work with makes it much easier. And the question of how to show the links depends on your data structure. So let's say you're using a 2 level array like this: ini_set('memory_limit', '64M'); function blank_map() { $map = array(); for ($y = -10; $y <= 10; $y++) { $row = array(); for ($x = -10; $x <= 10; $x++) { $row[$x] = array( 'terrain' => rand(0,1) ? 'grass' : 'sand', 'objects' => array(), ); } $map[$y] = $row; } return $map; } function display_map($map) { foreach ($map as $y) { foreach ($y as $x) { if ($x['terrain'] == 'grass') { print "\""; } elseif ($x['terrain'] == 'sand') { print "-"; } } print "\n"; } } $map = blank_map(); display_map($map); I'm limiting it to -10 to 10 for debugging. For -99 to 99 you will probably need to increase the memory limit. Is that the kind of thing you're looking for?
  20. This particular data is from a friend of mine who wants to assign dollar values to rankings. Rank 1 is worth $1,000,000, rank 100,000 is worth $5, and rank 50,000 is worth $200. But the general problem is one that I often want to solve for making heuristics that take rankings and various other data as input, and produce a score as output. For example, I may want to convert a keyword search count to a linear scale from 0 to 10, but I want the conversion to be log-like. Then I might want a function like: Search Count => Score 1,000,000 or more => 10 100,000 => 5 10,000 => 3 1,000 => 2 100 => 1 10 or less => 0 So the shape looks logarithmic, but a simple logarithm will never match all those points (though it might get close enough).
  21. Thanks for that keyword! I found a site which did logarithmic regression with a function aln(x) + b, but it couldn't make a curve fitting that data. Now I have an idea of where to look though!
  22. btherl

    Game

    I'm not entirely sure what your question is here Have you decided how you will store the playing field? A 2 level array?
  23. Let's say I have the following specification: f(100000) = 5 f(50000) = 200 f(1) = 1000000 Those are 3 points I've specified. I want a function f() which is a smooth, log-like curve that passes exactly (or really really close) through those points. Is there a method I can use to construct this function such that the final function can be implemented in php? The method of constructing does not need to be in php, just the function f() itself.
  24. I think his original problem is that get_headers() returns nothing on the live server. And the other original problem is that the result code does not indicate the actual result, as the server returns 200 for a 404. AquAvia, is the second argument to get_headers() an issue? Should it be 1? In your second post it is missing.
  25. get_headers() is php 5 .. is your live server php 4? curl is a module that strikes a balance between low and high level access. There's some examples here. It'll give you headers as well (check that it is actually installed on your live server though!)
×
×
  • 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.