Jump to content

vinny42

Members
  • Posts

    411
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by vinny42

  1. What I do is rewrite every URL that is not an images/folder etc to index.php and use $_SERVER to look at the URL and decide how to route the request. I've seen may people get into very deep doodoo trying to create a new rewrite for every different URL structure they have, especially when the original request also contained a parameter that you use in the rewrites.
  2. How would you suggest asking a browser to send all it's cookies when it is specificallty programmed to never ever do that? :-) You might be better of trying oAuth, then your visitors could authorize you to see some of their data on the remote site, if that site also uses oauth. But I'm affraid that you'll just have to live with the fact that you can't see data that is not meant for you.
  3. No, because the cookies that the remote site has set on your visitor's browsers are never sent to your website. And even if they were, there's probably some IP check done on the data so your site would be assumed to be a hacker.
  4. So you do have to login. cURL is not your browser, you have never logged in through cURL so cURL doesn't send any credentials to the remote site. It's up to you to make cURL login to the remote site and send the right cookies etc along.
  5. wrong URL? Do you have to login or send cookies?
  6. Sounds like you haven't fixed it right :-) It should read: curl_setopt($ch, CURLOPT_URL, "https://example.com/a/token.php");
  7. I trust that you did fix my copy/paste error in the URL line? :-) And of course you have now looked at the curl extension and you have looked at it's errorhandling functions etc so you can see why the request is failing?
  8. try running EXPLAIN on your query to see if the queryplans differ between the various methods.
  9. You can stop restarting the server, it makes no difference at all :-) Are you sure the results are the same? Isn't PHPMyAdmin adding a LIMIT statement? (PHPMyAdmin is crap that way)
  10. Well, Normally I'd flame you for not RT-ing the F'ing M, but because it requiers only two lines of extra code in the manual's first example: <?php// create a new cURL resource$ch = curl_init(); // set URL and other appropriate optionscurl_setopt($ch, CURLOPT_URL, "http://forums.phpfreaks.comcurl_setopt($ch, CURLOPT_HEADER, false); // make curl_exec() return the data instead of printing it.curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // grab URL and pass it to the browser$strFetchedHTML = curl_exec($ch);// write the data to a filefile_put_contents('/tmp/junk.html', $strFetchedHTML); // close cURL resource, and free up system resourcescurl_close($ch);?>
  11. Which website, yours or the remote site? And which of the many meanings of the word "cloudflare" do you mean? And how does using this cloudflare stop you from using cURL?
  12. The only way to guarantee that no cache is being used is by including SQL_NO_CACHE. Every other way is just assuming that no cache is being used, not guaranteeing. Have you made sure that phpmyadmin is talking to the same database as the rest? Does it return the exact same data as the other tools?
  13. If you google this for three seconds, you'll find a ton of references to the "cURL" functions. They are the only ones that do this correctly. fopen() etc require that the admin has enabled http wrappers, which is usually not desirable because of security issues.
  14. Try adding "SQL_NO_CACHE" to the query that you are tunning in phpmadmin, I'l willing to bet that your query will start taking minutes there too: SELECT SQL_NO_CACHE * FROM table WHERE... ; The only other possibilities are that you are not running the queries on the same database, or you are using a prepared statement which causes the database not to use indexes. Neither are very likely.
  15. And even there it's common practice to use InnoDB for the storage and use a trigger to sync it with a MyISAM table for the fulltext search columns. Another reason why I wonder why so many people keep using MySQL :-)
  16. It was, until 5.5 when MySQl finallt woke up to the real world. :-) If you have no contraints defined you have a very strange database design :-) But, more to the point, features that are not used do not slow the rest down. This appears to be a common misconception; the fact that a database can do something doesn't mean it's slower than a database that can't do something.
  17. A lot has been said about this, as you can see in the posted link. In the end though, there's only one thing that counts: reliability. MyISAM doesn't do crash recovery, it doesn't even do consistency checks runtime. If doesn't do foreign-keys and it doesn't do transactions. In short: MyISAM has no mechanism for making your data reliable. Worse, if you mix MyISAM and InnoDB, your InnoDB tables will do transactions, and your MyISAM will pretend to do transactions,and all your data goes down the drain. If you must use MySQL then *allways* use InnoDB. Some people will insist that MyISAM is faster but what good is a fast database if you cannot trust it to store your data reliably?
  18. The regexp checks if the string contains that, anywhere inside the string. So "fooMEDIA_IMAGE_12345" also matches (a very common and bugsensitive mistake). I'm not sure what MEDIA_IMAGE refers to Literally that text: "MEDIA_IMAGE".
  19. Does that mean no exception is thrown, or do you get "uncaught exception"? The latter is something you can get if your script is in a namespace, because you are catche "Exception $e" and not "\Exception $e"
  20. One the one hand, the code can't look familiar because you are not using the method I'm using. On the otherhand, nothing will drop into #21 because your real problem isn't about building arrays. What you need to do, at the most basic level, is recursively climb the tree from the source node untill you run into node 144 or until there are no mode parent nodes. There are no arrays involved at all, forget arrays, they are not relevant here. Just write a function that can fetch a record, check if it has a parent. if no parent stop. if it has a parent then check if that parent is the node you need. if yes; stop, be happy. If not fetch the parentnode, check if it's parent is the 144 node, etc etc.. That's what my code does, in a class structure, but that's realy how you should be programming anyway, if you want to keep your code easy to maintain.
  21. Well, if it was correct then you wouldn't be asking the question would you. :-) So tell us what is going wrong, do you get any errors, strange behaviour, what?
  22. I hate forums that use pagination :-) Maybe this helps to get back to the original problem of finding the parents in a tree, under the motto of "keep it simple". class pathFinder { /** * @var \PDO */ private $_objPDO; public function __construct($pObjPdo) { $this->_objPDO = $pObjPdo; } public function findInPath($pIntStartNodeId, $pIntNodeToFind) { // Find the parentid of the supplied node, but only if the parent_id is not NULL (top of the tree) if (false === ($objResult = $this->_objPDO->query("SELECT parent_id FROM recurse WHERE parent_id IS NOT NULL AND id = " . $pIntStartNodeId))) { var_dump($this->_objPDO->errorInfo()); exit; } // If nothing is found then stop. if (0 == $objResult->rowCount()) { return false; }; // If something has been found, check if it was wat we were looking for. $arrRow = $objResult->fetch(\PDO::FETCH_ASSOC); if ($arrRow['parent_id'] == $pIntNodeToFind) { return true; } else { return $this->findInPath($arrRow['parent_id'], $pIntNodeToFind); } } } echo '<pre>'; $objDb = new \PDO('mysql:localhost', 'demouser', 'demopassword'); $objDb->query("USE demos"); $objDb->query("DROP TABLE IF EXISTS recurse"); $objDb->query("CREATE table recurse (id integer, parent_id integer)"); $objDb->query("INSERT INTO recurse (id, parent_id) VALUES (1,null),(2,1),(3,2),(4,1),(5,1),(6,5),(7,6),(8,7)"); $objPathFinder = new pathFinder($objDb); // Is 4 a child of 1? var_dump($objPathFinder->findInPath(4, 1)); // Is 40 a child of 1? var_dump($objPathFinder->findInPath(40, 1)); // Is 4 a child of 8? var_dump($objPathFinder->findInPath(4, );
  23. Perhaps, but no code posted = no solution given... as multi-dimensional arrays aren't really a strong point of mine. That shouldn't really matter, you don't need them to solve your problem. I'll see if I can write up an example.
×
×
  • 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.