Jump to content

vinny42

Members
  • Posts

    411
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by vinny42

  1. I've seen some wonderful solutions made using the "code first, ask questions later" technique. Especially because once the solution "works", there's no need to ask questions anymore. So, no. Always ask before you write code. Worst case they tell you you were right, best case you get a solution that is far better than what you had in mind.
  2. You would ofcourse create the array when you want to start the search.
  3. What barand is saying is that you only want to know which nodes in the supplied array are descendants of 144. So if you make an array that contains *all* descendants of 144, you can just compare the two arrays. Whether this is an option depends on the size of your tree relative to the number of nodes you are looking for.
  4. Look at imagecopyresampled(), it is a little tricky but if you google for something like "php imagecopyresampled resize example" you should find tons of people who did this. Note; there is also imagecopyresized(), but imagecopyresampled() gives much better results when the image is resized.
  5. "$v = exec("convert ".$path.'o_'.$slika.".jpg -resize 150x500 ".$path.$slika.'.jpg');" Does the server still allow you to use exec()? Becauset that's a very dangerous thing and is usually disabled. Using the gd functions of PHP is safer and does the same thin to the image.
  6. "Warning: Illegal string offset 'content' in C:\www\mvc\libs\Words.php on line 14" As requinix suggests and as the error message is trying to tell you: whatever you are trying to get element 'content' from at line 14 is a string, not an array. Strings cannot have an offset of anything other than a number.
  7. Yup, that can work. I don't know if it's what you want or need, but it can work. Go ahead, I don't know what you're trying to do so goodluck!
  8. You souldn't try things out, you should read about what you are doing and fix your mistake. You cannot LEFT JOIN during an insert because you are creating a new record so there is no record to join yet. Perhaps you should start by saying what you want to achieve, there mist be a reason why you wanted to use the JOIN?
  9. That's a matter of documentation. If you don't know PHP then a PHp solution is not going to be any easier to read. More to the point; is this soemthing the database should do and can do? For MySQL the answer is no, MySQL cannot do recursion by itself, so you'll have to do the recursion in PHP. That does *not* mean that you load all records in PHP, because PHP isn't opartcularly brilliant at processing lots of data either. For PostgeSQL the answer is yes, PostgreSQL can do a recursive selfjoin, which does exactly what is required here.
  10. Nested set is brilliant for finding parents and entire trees, but it is pure hell to maintain as the tree gets bigger. A simple compromise is to add a new column that holds the entire path to each record, reducing the problem to a LIKE query, which may or may not be faster than recursing through the parents. (MySQL cannot index for LIKE, other databases can use TRIGRAM indexes which are designed for this purpose)
  11. How can I help if you just post an error, especially if that error tells you exactly what the problem is...
  12. You cannoty access a URL asif it is a directory on your local filesystem.
  13. Or array_count_values :-) Or just us $votes[$vote['type']]++ to cout directly in the $votes array.
  14. Ok, so what is the "error" text? What does the script print on the screen?
  15. Cookies are most likely yes. Check the cURL manual, if anything can do it, it's cURL.
  16. You cannot update the field, that's the problem. You have to store *all* the data and you cannot, ever, change any of it, in any way. So updating is not even relevant i the first place.
  17. When you submit the form the remote server will send you something that it can use to identify you by. It you don't catch that data and send it along in your next request then the server will assume that you are not logged in. So you'll have to investigae how the login process works. You should probably also think about what you want to do; if the remove server want's you to be able to automate the posting , wouldn't it have an API?
  18. The biggest threat is SQL-injection. The script takes data from the POST vars and puts it directly into the query, which means that a hacker can literally put anythng he wants into the query. That incluses subqueries that do nasty things like create new admin accounts, drop the entire database, etc. Like Ch0cu3r says: this script is old (http_post_bars has been removed from PHP for years) and needs to be re-written with security in mind.
  19. You could do that; make large gaps and put new numbers right in between. inserting between 100 and 200 yould be 150, between 100 and 150 at 125 etc. But in the end that's just postponing the envitable, you will have to renumber some time.
  20. True, but that is one query: UPDATE table SET order_column = order_column+1 WHERE order_column >= X; where X is the order_column value of the first record that needs to be moved. And you could even stick that in a trigger and not have to worry about it ever again. :-) You should perhaps use a separate table for this data, the sortorder itself is not part of the daa being sorted and if you ever decide to sort the same items differently in two dropdowns (of wherever) you don't want to have to add a new column every time.
  21. +42. If you're not doing anything with processing or distribution then files go in the filesystem. That said, you might be able to put the binary data of the image in the tag itself, which would reduce the number of hits your server takes (but if you want to reduce hits you have a busy server and a busy server shouldn't have a huge datafile for the database unles it's a big server...)
  22. I know that, but you are ignorING what is being said. Like now, you are asking about how to update, but do you know why you want to update, or even that you *can* update these records?
  23. What's the point? You are just going to ignore what's being said and do your own thing, just like you are doing now. I've already told you that you cannot simply merge data, but you do it anyway.
  24. I've modified the user example from the manual a little. It calls a URL containing a script that just has "sleep(1)" in it. If you run the code it will return in just over one second, while it has called the URL three times, so in blokcing mod it would have taken over three seconds. function multiHTTP($urlArr){ $sockets = Array(); // socket array! $urlInfo = Array(); // info arr $retDone = Array(); $retData = Array(); $errno = Array(); $errstr = Array(); for ($x = 0; $x < count($urlArr); $x++) { $urlInfo[$x] = parse_url($urlArr[$x]); $urlInfo[$x]['port'] = (isset($urlInfo[$x]['port']) ? $urlInfo[$x]['port'] : 80); $urlInfo[$x]['path'] = ($urlInfo[$x]['path']) ? $urlInfo[$x]['path'] : "/"; $urlInfo[$x]['query'] = (isset($urlInfo[$x]['query']) ? $urlInfo[$x]['query'] : ''); var_dump($urlInfo[$x]); $s = fsockopen($urlInfo[$x]['host'], $urlInfo[$x]['port'], $errno[$x], $errstr[$x], 30); if (false !== ($s)) { $sockets[$x] = $s; socket_set_blocking($sockets[$x], false); $query = ($urlInfo[$x]['query']) ? "?" . $urlInfo[$x]['query'] : ""; $strHTTPRequest = "GET " . $urlInfo[$x]['path'] . "$query HTTP/1.0\r\nhost: " . $urlInfo[$x]['host'] . "\r\n\r\n"; // echo $strHTTPRequest; fputs($sockets[$x], $strHTTPRequest); $retData[$x] = ''; } } // ok read the data from each one $done = false; while (!$done) { for ($x = 0; $x < count($urlArr); $x++) { if (false === $sockets[$x]) { unset($sockets[$x]); continue; } if (!feof($sockets[$x])) { if ($retData[$x]) { $retData[$x] .= fgets($sockets[$x], 128); } else { $retData[$x] = fgets($sockets[$x], 128); } } else { $retDone[$x] = 1; } } $done = (array_sum($retDone) == count($urlArr)); } return $retData;} var_dump(multiHTTP(array("http://localhost/a.php?wait=1", "http://localhost/a.php?wait=2", "http://localhost/a.php?wait=3"))); exit;
×
×
  • 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.