Jump to content

Anidazen

Members
  • Posts

    79
  • Joined

  • Last visited

    Never

Everything posted by Anidazen

  1. Hey guys. I've long been after a version of CURL that can download multiple sites at once instead of one-after-another. I've come across this library (PECL). It's linked from the CURL site: http://pecl.php.net/package/pecl_http It says parallel requests are available in PHP5+, which is awesome news! It sounds like what I was looking for does, indeed, exist. The problem is that I'm semi-skilled with PHP, but I've NEVER done anything with libraries, and I really can't get my head around this at all. I couldn't even make out if this was included in PHP by default (like CURL), or if it's something you include in the PHP build, stand alone includes or what. If anyone could point me in the direction of making simultaneous transfers, I'd be extremely grateful.
  2. Cacheing has always been a big "what if" decision with the site, and one we've gone against. The reason is that queries are split amongst 720 distinct queries, and there's no way to consolidate that. It's like a price comparison, but with 720 different pages of products - and 20 sellers to consider for each. The data also changes frequently. So until I'm getting > 720 queries a day, cacheing is a bigger load overall, and a real pain in the ass for my partners' sites - apart from anything else. Size of query data might just be the problem here - move from text to blob would help? Edit: The query is an INSERT, with 3 small values ( < 10 characters) and then one massive one. Here's a sample of the bigger one: ".19.114.130','32.99~64.65~~155.98~302.98~448.83~591.86~~###23.27~46.21~~114.72~224.63~336.95~449.27~673.90~###~68.99~101.99~169.99~~502.99~665.99~990.99~###22.98~45.88~68.68~114.23~226.40~339.28~451.95~~###20.40~~59.42~97.09~192.25~285.49~376.85~559.63~923.38###31.99~54.99~76.99~122.99~227.99~337.99~445.99~654.99~###35.77~61.77~81.77~129.77~236.77~348.77~459.77~674.77~###~~~~~~~~###31.63~61.94~~149.20~289.42~428.50~564.74~~###~~~~~~~~###28.94~56.49~73.99~135.29~261.17~366.99~~~###22.98~44.98~67.98~112.98~224.98~~~~###26.09~47.95~67.16~103.99~192.19~278.09~365.63~~###23.59~47.18~70.77~117.95~231.18~343.23~452.93~679.39~1,108.73###23.29~46.58~69.87~116.45~228.24~340.62~451.83~670.75~###29.00~~79.08~131.80~263.59~395.39~527.19~~###~40.35~60.40~100.27~199.14~~397.48~595.02~987.72###21.50~42.50~63.50~105.50~210.50~313.50~417.50~625.50~###38.20~~~124.15~233.02~343.80~454.58~676.14~###~~~~~~~~###'"
  3. It was once fopen(), then upgraded to CURL, and then on to a semi-custom third party class which is higher still performance. I put in those logs to email me when it crashes, and - apart from the stress of knowing 8 customers were let down today - I got some information. The errors were all one of the following two: - Error: Lost connection to MySQL server during query - Error: MySQL server has gone away I'm assuming that this is simply beyond my power to fix without changing host? In the mean time, is it possible to set a small max SQL timeout, then loop until it actually works?
  4. Thanks for the advice. How would I go about logging the script to a file? Also - the only thing I know is mysql_error(). Should I just record all kinds of variables and everything for reference?
  5. I am assuming it must be an SQL timeout, as I will eventually get an "INSERT FAILED!" message - which is what's set to my mysql_query() or die("INSERT FAILED!"). No idea on random causes? What I think I'm gonna have to do is to program some error detection for when this happens - presumably I could attach: or die("Insert failed" . mail("my email","Script Died...",mysql_error() . "-/-/-/-/-/-/-/Original query: " . $query)); - That would at least tell me if it was a SQL error? Problem is, it's so rare that I can't simply debug it...
  6. Hi guys. I've got a script I've worked very hard on, and it's a commercial script - fetching prices from various sites while a user waits. Anyway, quite obviously when you're paying big for customers, a script randomly failing is an absolute disaster. My script will perform well 90% of the time, usually loading in < 10 sec with all prices fetched. However, sometimes it will randomly go up to 30 seconds, then die with an "Insert Failed!" - which is what I put in for SQL failure. I can only assume this means an SQL timeout or some such shinanegans. With the [i]exact[/i] same parameters, the results literally vary from time to time - 90% smooth, 10% this random issue. Is it something I can correct? How can I fix this? If it [b]is[/b] random SQL timeouts, then 1) How can I improve that performance, and 2) How can I avoid the problem? I don't suppose there's a way to set my SQL timeout to be like 5 seconds just for certain files, then in case of failure just loop (with a max tries) until the bloody thing works, lol... Any thoughts? I'm used to all kinds of problems with PHP, but at least they're usually consistant! - It does occur to me that because the script is very complex and processes outside info, I don't have 100% control over all variables... it could still be something external perhaps?
  7. Hello. I really hope somebody can help me. I've got a complicated results ordering question. Basically, I've got some prices in an array called $pricearray, and it looks something like this. $pricearray[$i] = array("site logo", "site name", "site url", "site url 2", $sub-price-array); So it's some information about the seller, and $pricearray[4] contains an array of prices for different objects. Now [b]before[/b] the fourth field was turned into an array, I was able to re-order $pricearray via the price contained in value 4 of the array. Someone on this forum was kind enough to supply me with the following code for doing this, months ago. [code]$tmp = array(); foreach($pricearray as $k => $v) { $tmp[$k] = $v[8]; } asort($tmp); $new = array(); foreach($tmp as $k => $v) { $new[] = $pricearray[$k]; }[/code] $new would basically be $pricearray but re-ordered based on the value of field number 4 in the array. The problem is I've never understood what's going on in this code, so I'm helpless to adapt it! I need it sorted by the value in $pricearray[4][$i] basically, where $i is the object number. I hope this makes sense. Edit: I believe the 8 in the quoted code should be a 4. This is because $pricearray now has fewer values than when I copied/pasted that bit of code. However, I've tried changing the "$tmp[$k] = $v[8];" into "$tmp[$k] = $v[8][$i];" and it doesn't achieve the desired result.
  8. Hello. I'm trying to do some pretty fancy parsing/website interaction. Highly ambitious project. What I'm trying to do is to basically complete the shopping cart of an affiliate but to do it on my site. I have the blessing of the owners btw, as long as I can manage it on my own. So I'm assuming all I need to do is to do each step the user would do, returning the cookies I have been given and form variables I have been given and/or would have filled. The big problem is, once a user has paid by PayPal (direct to the merchant), this will trigger one of those 'on return' PayPal scripts. This will mark it as paid in their database, but I won't have a clue. Is there any way to get around this?
  9. Hey. I'm pretty interested in using PHP to retrieve and parse websites, and to generally simulate the browser as closely as possible. I'm taking on more and more advanced projects, and it's becoming harder and harder just to track what is said between browser and server. Are there any tools that can easily help with this? Some useful tools would include: - Showing what cookies are set and when. (Maybe their values too.) - Showing what cookies are accessed and when. (Their values too.) - Anything that can compare two pages of source code and highlight any lines/sections/form values/links that have changed. If anyone knows anything like this, or other tools that would be useful in helping build parsing applications, please let me know! Basically the kinda thing you need to try to recreate exactly the browsing experience when dealing with a complicated script.
  10. Unless I'm missing something can't you just list all the IDs in the same table-field, seperated by commas? Then just reference them with "WHERE category_ID LIKE '%$id%'" instead of "WHERE category_ID = '$id'"
  11. I believe I might be able to help slightly. Do you want it automatically to be printed for the user? That's dealt with via. javascript - search for javascript print tutorial or something similar, a million results will surely come up. If you're wanting to auto-print pages for your own personal needs it's a little harder... as the confirmation box will always need pressing for most people. I believe there are ways to get around it though, one I remember was to email the page to yourself and use a particular email client.
  12. Steve, the line that matters in doing that stuff is this one, quoted from Craygo's script: [i]$sql = "SELECT * FROM tablename WHERE width < '$width' AND height < '$height'";[/i] If we want it to be less than 1 then it becomes: $sql = "SELECT * FROM tablename WHERE width < 1"; If we want it to become less than 3 and more than 2, it becomes: $sql = "SELECT * FROM tablename WHERE width < 3 AND width > 2'"; That's the SQL statement that matters in this example.
  13. Hmm, seems that in your environment/form method you do need to use these things:   $email = $_REQUEST['email'] ;   $message = $_REQUEST['message'] Do that for all of the variables, and put the lines at or near the top of the script. See if that helps. The header warning... I'm not entirely sure. This redirect is definitely causing the problem: [i]header( "Location:  http:thankyou.htm" );[/i] And the problem is that this is a header based redirect, so it can't happen after even a single line of html has been passed. However, I don't know why it thinks some has. Possibly changing the first thing would help here - I don't know. Add those extended variable definitions and post back.
  14. My guess would be all code will have a loop that goes through producing page links. Just change this from a loop that outputs all links, starting with $i or similar as 0 and going to the end, to starting at $i = $current -3; and going to $ii = $current + 3; if that makes any sense?
  15. <? $newmessage1 = "Customer Contact Form Results. Subject: $subject Full Name: $title $firstname $secondname Telephone: $telephone Email Address: $email Message Body: $message";   mail( "yourname@example.com", "Feedback Form: " . $subject,     $newmessage1, "From: $email" );   header( "Location: http://thankyou.htm" ); ?> any help would be greatly appreciated, cheers [/quote] That should do the trick, the subject chosen will appear in the email subject as well as an added touch, lol. It's pretty important that you understand what I did though - the message we send is simply this variable in your code - the one I've highlighted: mail( "yourname@example.com", "Feedback Form Results",     [b]$message[/b], "From: $email" ); - I  renamed it but it doesn't make a difference. Whatever $message is (or $newmessage, now I changed it) is what gets sent. It's a variable like any other, so I simply made it like any other. :)
  16. I know this sounds stupid, but ya did remember to enter the info into your live DB? It's not just failing to lookup the password because you didn't put anything in there?
  17. Forgot to mention, you'd need to change the 'message' value you're sending to the mail() function to $newmessage, from $message. PS: If you don't get this I can show the whole edited script for ya, just ask. This way though I'm trying to show ya why the changes work and what's been done. Easy to understand - just the value you pass in that mail() function where $message is should be changed to whatever you want yourself to be sent. :)
  18. Not entirely sure what you're after here Michael! You want them to enter their surname, address etc. and have it displayed along the message in the email you receive? The key to this is $message. That's basically what you get sent. At the moment, the user puts their message in $message, and it gets sent - as is - to you. What we're gonna need to do is change it before sending it. Something like this: $newmessage = "Name: $name Contact Email: $contactemail Address: $address Other Value1: $othervalue Other value2: $othervalue Customer's Message: ". $message; Adding these lines to your existing script should do the trick. In this example, $name, $contactemail, $address, $othervalue1, $othervalue2 are all values passed by your form. PS: You shouldn't have to do "$email = $_REQUEST['email'];" for your values? Should work without. Try it. If you do need to do this for values, you'll need to do it for the new ones too.
  19. If I understood you correctly, you might need to modify what Orio said slightly, to select where height < x or > x.
  20. Firstly - thankyou for the way you worded your query, great to see respect like that for other users. :) Secondly, I'm a middle-competence coder at best, and often need to use these forums myselves to ask the real coders for advice and help -- so I don't know how qualified I am to answer your questions, but I'll give it a shot! What I do know is that it's DEFINITELY not just the output size that's gonna have an impact on loading speeds. This isn't even the main element. Output size may matter on some level, but computing time is what you need to worry about. I'm pretty sure you can have anything in if conditions, without it effecting the runspeed unless the condition is met. (The check itself presumably takes some time, but we're talking seriously nothing.) Some ways of doing the same function are more efficient, and optimising code aims to get memory usage etc. down as well as page load time. To be honest, you shouldn't worry hugely - just try and make code clean. For what you've described, I doubt optimising is of vast importance: if it's slow, it's probably your server. Having said that, try to do things in the cleanest order, try to avoid unnecessary tasks (eg. always retrieving some info that you only need occasionally... check first, etc.). But seriously dude, for what you're describing the difference between clumsy and streamlined code should be very close on impossible to notice... slow is probably a server issue instead. If you've bottlenecks slowing your script, you should really be able to identify what they are -- a loop repeating something 600 times over is gonna take some time - looking up pages takes time, etc. One thing you can do is output the time it takes your scripts to run and make tweaks, seeing which of two ways are faster. Secondly, computing time and script size are very, very different concepts. I could write a 5 line loop that takes hours to load, and a 2,000 line script that takes seconds.
  21. Not entirely sure what you want here, but you can use CURL to load another script from within your own - that can entirely simulate posting the form itself - the output from the first script could in itself be a return with this method, assuming you can customise both scripts. You might be wanting to include the second script. If this is the case, you can use functions from the second script, but all returns need passing through an array: return $whatever. Third option, if you're wanting to just bounce a user backwards and forwards between scripts, you could just use a simple refer?
  22. Print you really are a legend. You've no idea how much this is gonna help me out. Guess there are some really genuinely helpful people around. :D Very much forwards to the PM. It occurs to me: I've spent a looooooong time looking, and I couldn't find a way to do this before you released this. You might want to stick it on SourceForge? Solves a real need.
×
×
  • 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.