Jump to content

sloth456

Members
  • Posts

    171
  • Joined

  • Last visited

    Never

Everything posted by sloth456

  1. in reserv-1.php edit $to = "cabosail@gmail.com"; put your email in. I don't understand exactly what isn't working, do you get any error messages? What happens when the script runs.
  2. umm there are several decode functions like utf8_decode() etc. If there's a way you can parse out the type of encoding, then just use an if statement that says if it's UTF8 use this decoding method, it it's ISO do this, etc.
  3. Can you go more into depth. Show some code. I can't think of a reason off the top of my head why php would automatically change a string it gets from an external source.
  4. @RussellReal I understand what you're saying, but sometimes php.net won't be enough to understand how to implement a command properly. In this case a tutorial is very helpful. Take for example unzipping a zipped file on your server. There's a lot of commands required to do it successfully, I needed a tutorial to get my head round it.
  5. I started out by wanting to achieve something and then googling everything I could. I also downloaded scripts that other people wrote and tried to see how they worked. However, I did find that "PHP and MYSQL for Dummies" cleared up a lot of things I was confused about. Nice easy book which can be read from the beginning or you can easily skip to the page with the info you need to know more about.
  6. Hi, I'm trying to build a split tester tool that will compare the click through rate of 2 adverts and tell me how confident I can be there is a statistical difference between the 2. For example Ad 1 has a CTR of 1.97% Ad 2 has a CTR of 0.52% You can be 90% sure that the ads will have a differences in the long run. The significance figure above is just an example not actually calculated to be correct. I have no idea how to calculate statistical significant difference. Any help?
  7. Not sure but your whole implementation seems wrong. <?php $package; $package["name"] = $_SESSION['SESS_NAME']; $package["price"] = $_SESSION['SESS_PRICE']; $package["date"] = $_SESSION['SESS_DATE']; $package["sport"] = $_SESSION['SESS_SPORT']; foreach( $package as $key => $value){ Your session variables can each only hold one string, so whatever you last defined it as is what it is. You can't add to them like arrays (at least i don't think you can). So it's no wonder that when you print out all your items, they all come up with the same values.
  8. sounds like a lot of work. I'm not gonna go right into a full blown solution here with written code, but here's some tips. Put your form(s) html in a seperate file and at the top of each file put if(isset($message){echo $message;} Then in the main file whenever you want your form to come up you can just use something like $message="you've entered something incorrectly"; include("form.php"); Another tip for form processing is use a switch statement. $do=$_GET['do']; switch($do) { case validate: //validation process here //if validation fails $message="Validation failed"; include("form.php"); //if successful //execute some code - maybe put some details into a database //go to thank you page or success page header(location:'thankyoupage.php'); //end this junk 'o code break; default: include("form.php"); } Now just make sure that your form action in forms.php is "yourmainprocessingfile.php?do=validate" You were also asking about carrying data from one page to another. Are you aware of SESSION variables. If you need a bit of info to carry around do the following. Firstly at the top of each file that will be using these session variables you need to use session_start(); Then say you can just say something like $_SESSION['username']="whatever username"; And call it later like this echo $_SESSION['username']; doesn't matter what you call it, can be anything $_SESSION['dog'], $_SESSION['cat'], $_SESSION['I really like monkeys far too much']
  9. try the following as your regular expression '/<tr style="background-color:#cccccc;">.*?<a href="(.*?)".*?<\/table><\/td><\/tr><\/table><\/td><\/tr><\/table>/' .*? just means "skip over whatever is here" (.*?) means "grab this"
  10. You're in luck, just spent a million years myself getting to grips with scraping, annoying at first, but once you crack it, it's useful as hell. Try this: $file = file_get_contents('http://tv.bascalie.ro/program~data-20-decembrie-2008~post-pro-tv.html'); preg_match_all('/<tr style="background-color:#cccccc;">(.*?)<\/table><\/td><\/tr><\/table><\/td><\/tr><\/table>/', $file, $matches); print_r($matches); made 3 changes to your code. 1) In the regular expression area you've started with "/ and /", I've changed the m to '/ and /'. Much easier because then you do not have to escape all your double quotes with back slashes. 2) I've changed (.*) to (.*?), trust me I know very little about regular expression. But (.*?) is about the only thing I ever use, it just means "grab whatever's here". 3) I've changed echo $matches[0] to print_r($matches). print_r is a nice little command that will output the full array with numbers as well so you can see where your content is stored. Usually when I'm doing this kind of scraping I find that $matches[0] does not contain what I want and $matches[1] does. Take a look and see which bit you need. A full tutorial can be found at http://www.thefutureoftheweb.com/blog/web-scrape-with-php-tutorial If you need anymore help, I'll see what I can do.
  11. I know this is kinda late, but I noticed your database selection statement looks a little odd. you've put: mysql_select_db($database); should it not be mysql_select_db($database,$connect); To be able to select a database you must pass it the connection too. Hope this solves the problem.
  12. ok, managed to solve this one on my own. For those of you who don't know anything about email attachments I'll start from the beginning. The attachment doesn't come in physical form. It comes as a piece of text (a string to be more technical), which must then be decoded to make it into the actual file. The string can be accessed with the follwoing line imap_fetchbody($conn, $emailid, 2); where $conn is the connection you made earlier and $emailid is the email number you're accessing. The number '2' is the "part" that the attachment is in. I've deliberately set it to '2' because I know that part 2 of my email contains the attachment I want. If you have multiple attachments, you'll have to loop through each part number. If you were to echo this, you'd probably get a long string of characters. This is your attachment coded into a piece of text. To decode it you'll need to know how it was encoded. For me I knew my "piece of text" was encoded in base64. So I just used base64_decode($thecodedtextgoeshere); to decode it. If you want this in a downloadable form you'll then need to use fopen() and fwrite() to write this file to your server/hosted area. This is what I did: //grab the attachment (which is just some text at the moment) decode it and stick it into $file $file = base64_decode(imap_fetchbody($conn, $emailid, 2)); //the file may be decoded but its still in text form, so write that text into a physical file on your server and you can open it! $fp = fopen('xml-report.zip', 'w'); fwrite($fp,$file); fclose($fp); Your file should now be located on your server. I knew my file was a zip file so I created a blank zip folder on my server called 'xml-report.zip' and wrote the string to that. For my purposes I also needed to extract the zip on the server so I could read the contents of one of the files inside. $zip = zip_open("xml-report.zip"); if ($zip) { while ($zip_entry = zip_read($zip)) { $fp = fopen("extracted/".zip_entry_name($zip_entry), "w"); if (zip_entry_open($zip, $zip_entry, "r")) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); fwrite($fp,"$buf"); zip_entry_close($zip_entry); fclose($fp); } } woop! zip extracted and contents put into a folder called "extracted/" Now you can just use fopen and fread again if you want to actually parse out some data from one of those documents. Hope this helps, I notice a lot of people having problems getting attachments from emails.
  13. I've searched the forums and google and almost get the answer but then not quite. There is a particular email I'm downloading and it has a zip file attached to it. I've managed to extract the attachment which just comes out as a long string base64 encoded. I've used decode_base64 and get another wierd looking string, presumably this is the actual ZIP. Now it seems I'm unable to read this string using zip_read(), I presumed the string I provided it was the resource but not so, just an error saying it's that it was expecting a resource. Can anyone help? Have I gone wrong further down the line?
  14. Try this tutorial http://www.devarticles.com/c/a/PHP/Create-Your-Own-Mail-Script-With-PHP-and-IMAP/
  15. Thanks very much, it was very kind of you to take the time out to show me. I did look through those pages and made some code to test it out, but obviously I missed something obvious. Thanks again. Interestingly the number of inlinks returned by the script is slightly different than the number that site explorer returns when you go and input it manually. For http://www.google.com I got 297,789,280 using the script and 297,779,166 through inputting the URL in site explorer manually. Any idea why? I set the search for 'Show Inlinks: From All pages to: Only this URL'
  16. All I want to do is find out the number of links pointing to a page using Yahoo's API. I've played around with the request URL but haven't been able to return a result that shows the data I want in it anywhere. If you want to have a go, the info is at http://developer.yahoo.com/search/siteexplorer/V1/inlinkData.html
  17. Thanks bobbinsbro, but that didn't quite work, I still pulled out the href=". @samshel: I think you found me the solution.
  18. Could it be a syntax problem in your insert statement shouldn't ,".time().", be ,'".time()."',
  19. Hi, I hate to ask, I feel like such a leecher rather than a contributor. I was wondering if anyone would help with the following problem. This is my code: preg_match('/<a href="(.*?)".*?<\/a>/',$googleresult,$matches); I've basically gone and scraped one page of listings from google using file_get_contents and put it in $googleresult I have stripped out all domains with "google" in them which leaves me with just the URLs for the actual listings. I'm basically trying to pull JUST the first URL between anchor tags out. I'm really useless with regular expression and so used http://www.thefutureoftheweb.com/blog/web-scrape-with-php-tutorial for help. Trouble is I seem to be pulling out more than just the URL <a href="http://java.sun.com/docs/books/tutorial/getStarted/application/index.html" class=l>Lesson: A Closer Look at the "<em>Hello World</em>!" Application (The Java <b>...</b></a>%20-site:<a href="http://java.sun.com/docs/books/tutorial/getStarted/application/index.html" class=l>Lesson: A Closer Look at the "<em>Hello World</em>!" Application (The Java <b>...</b></a>
  20. Thanks for the fast reply - I've used those wierd apostrophe's before but just couldn't remember the syntax. Anyway, everything works now! Problem solved.
  21. Ok, this has been irritating the £$%* out of me for the past hour and a half. I've sucessfully connected to my mysql database and am using the following code to select some data $sql="SELECT url,anctext,aclinks,linkcap FROM clientsites WHERE index='$siteid' AND active='1'"; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result); I get an error pointing to the first line saying there's some kind of SQL syntax error. If I remove the WHERE index='$siteid' AND active='1' it pulls the data fine, just not the exact data I want. Essentially I'm asking, what's wrong with this line $sql="SELECT url,anctext,aclinks,linkcap FROM clientsites WHERE index='$siteid' AND active='1'"; I'm thinking I've made a simple error, but just haven't spotted it. Any suggestions?
×
×
  • 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.