Jump to content

stubarny

Members
  • Posts

    122
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

stubarny's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Hi, Please could you tell me how to control a robot from a php script? I've been looking at raspberry pie based robots on the internet but they don't seem to use php as the controlling code. For example if I receive an order on my website, how do I use php to activate a product dispenser to drop a product onto a robot, and then use php to direct the robot to a packing area? Thanks for any pointers. S
  2. $result returns "Resource id #5" if I use echo or print_r, which i think is normal?
  3. Hello, This is confusing me! - this code is finding 2 rows of data ($nrows is 2), but I'm only getting 1 row of data returned. On the second while loop I'm getting the following error message: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/website.com/test.php on line 26 $query ="SELECT * FROM Accounts WHERE (jaaLatitude = '' OR jaaLongitude = '')"; $result=mysql_query($query) or die ("Connection to database table failed." . mysql_error()); $nrows=mysql_num_rows($result); $i = 0; if ($nrows > 0) { while($record = mysql_fetch_array($result, MYSQL_BOTH)) { $jaaIndex = $record[jaaIndex]; $jaaEmail = $record[jaaEmail]; $jaaLocation = $record[jaaLocation]; $jaaLongitude = $record[jaaLongitude]; $jaaLatitude = $record[jaaLatitude]; echo "<br>test jaaEmail is $jaaEmail<br>"; $i = $i + 1; } } As I say the first while loop is working, so I don't see what can be wrong with the qurery (it's not failing). Thanks for your help, S
  4. I'm looking to download a file and save it to my server. the link http://webmail.website.com/src/download.php?mailbox=INBOX&passed_id=6475&startMessage=1&override_type0=text&override_type1=html&ent_id=2&absolute_dl=true INITIATES the download (it is not the file being downloaded), and the file being downloaded it called test.html. At the moment I have to hard code in my php script to call the downloaded file "test.html", shouldn't I be able to find the file name from the downloaded file? Secondly I don't know how to download non html files with CURL - I've tried to download .pdf and .docx files and both have failed. Is it possible? Thanks, Stu
  5. The download link is: http://webmail.WEBSITE.com/src/download.php?mailbox=INBOX&passed_id=6475&startMessage=1&override_type0=text&override_type1=html&ent_id=2&absolute_dl=true and that link successfully downloads a file called test.html I then save that file as "test.html" but I've had to hard code the file name and the extension in the code of my first post. I want to have the code automatically find the file name and extension. Is this information not somewhere in the $data variable?
  6. Hi, The file extension of the download file isn't in the URL. The URL prompts the download, and the file is then downloaded. I need to know how to capture the file name and the extension from the file (not the url). Does that make sense?
  7. Hello, I have managed to find, retrieve and save a file using CURL. But I am having to hard code the file extension, is there a way to find the file extension automatically? (it seems the file extension isn't within the download URL) (also, is there a way of getting the file name so I can save it as the same filename - that would be great) Thanks for your help, Stu p.s. I've tried the pathinfo($url) function, but that gets information out of the download URL rather than the download file. $url="http://webmail.WEBSITE.com/src/redirect.php"; $cookie="cookie.txt"; $postdata = "login_username=USERNAME&secretkey=PASSWORD&js_autodetect_results=0&just_logged_in=1"; # get the cookie $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt ($ch, CURLOPT_REFERER, $url); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); curl_close($ch); $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); //read cookies from here curl_setopt($ch, CURLOPT_URL, "http://webmail.WEBSITE.com/src/right_main.php"); curl_setopt($ch, CURLOPT_HEADER, 0); $result = curl_exec($ch); curl_close($ch); # download file $source = "http://webmail.WEBSITE.com/src/download.php?mailbox=INBOX&passed_id=6475&startMessage=1&override_type0=text&override_type1=html&ent_id=2&absolute_dl=true"; $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); //read cookies from here curl_setopt($ch, CURLOPT_URL, $source); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSLVERSION,3); $data = curl_exec ($ch); $error = curl_error($ch); curl_close ($ch); # !!! The line below needs to be automated !!! $destination = "./files/test.html"; $file = fopen($destination, "w+"); fputs($file, $data); fclose($file);
  8. yes but I'm not calling those links (so I can't fix them?) - the email login page calls them on the server side? I don't see why me using curl makes the relative links to fail
  9. OK great, getting closer! I can see the structure (there's a frame divide where I expect it to be), so I'm convinced I'm logged in and the inbox webpage if being (partly) returned. But I'm getting two errors returned: Not FoundThe requested URL /left_main.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Not FoundThe requested URL /right_main.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. I don't really see why the files wouldn't be found due to an incorrect file path, because I thought curl just requests the webpage - if that webpage requires other files aren't those files called server side? (I've visited the squirrelmail inbox manually and it definately works). Here's the code that's almost working: $url="http://webmail.WEBSITE.com/src/redirect.php"; $cookie="cookie.txt"; $postdata = "login_username=USERNAME&secretkey=PASSWORD&js_autodetect_results=0&just_logged_in=1"; # get the cookie $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt ($ch, CURLOPT_REFERER, $url); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); curl_close($ch); # retrieve the inbox page $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); //read cookies from here curl_setopt($ch, CURLOPT_URL, "http://webmail.WEBSITE.com/src/webmail.php"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch);
  10. Thanks, yes my (very limited) curl experience is about 2 hours in total! I've tried adding an extra section to retrieve the page after initialising the cookie, but I'm still getting a blank response with the code below, I guess I'm still doing something wrong? ... $username="my_user"; $password="my_passs"; $url="http://webmail.WEBSITE.com/src/redirect.php"; $cookie="cookie.txt"; $postdata = "login_username=USERNAME&secretkey=PASSWORD&js_autodetect_results=0&just_logged_in=1"; # get the cookie $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt ($ch, CURLOPT_REFERER, $url); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); echo $result; curl_close($ch); # retrieve the inbox page $url="http://webmail.WEBSITE.com/src/webmail.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); //read cookies from here curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_REFERER, $url); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); curl_close($ch);
  11. OK thanks, I've checked that my host has CURL (which it does) and have tried the code below. I remembered to add the hidden variables but I still just get a blank page. Am I missing something? Thanks, Stu $url= "http://webmail.MY_WEBSITE.com/src/redirect.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); # POST variables $postdata = "login_username=USERNAME&secretkey=PASSWORD&js_autodetect_results=0&just_logged_in=1"; curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $output = curl_exec($ch); echo $output; curl_close($ch);
  12. Hi, I need to log into a website to check for the latest data, and I want to automate this with php script that will use a cronjob to log in, retrieve the data and email it to me. Currently I'm stuck on the logging in part (I'm testing the script below on my squirrelmail email login page). I've tried using the snoopy php class (sourceforge.net/projects/snoopy/) but it seems the POST variables aren't being recognised (because the email program is directing me to the log in page, as opposed to telling me that my username/password is wrong). (is it even possible for a servers to accept POST variables in this way??? I'm kind of surprised but lots of poeple seem to use snoopy to login via userforms) Please could someone point me in the right direction? Thanks, Stu / load the snoopy class and initialize the object / $snoopy = new Snoopy(); / set some values / $login_form['login_username'] = 'MY_USERNAME'; $login_form['secretkey'] = 'MY_PASSWORD'; $snoopy->cookies['vegetable'] = 'carrot'; $snoopy->cookies['something'] = 'value'; / submit the data and get the result / $snoopy->submit('http://webmail.MY_WEBSITE_NAME.com/src/redirect.php' $p_data); / output the results / echo '<pre>' . htmlspecialchars($snoopy->results) . '</pre>';
  13. Hi All, I'm very comfortable with PHP/MYSQL programming but my websites look very basic visually (e.g. like craigslist.org). What is the best way to apply a good website graphical design? I've noticed a lot of nice looking wordpress websites but I would prefer to have complete control over the PHP/SQL database. Any ideas? Thanks, Stu
  14. Hi, Thank you very much for your help - I've tidied up the field names (I've left the initial of the table name just so that the php variables are ready-named when I retrieve them out of sql), and I've removed the ID field on the correlations field as suggested. Keyphrases: kID | kContent 1 | Accountant 2 | Management Accountant 3 | Financial Accountant JobAdverts: jaID | ja_kID 1 | 1 2 | 2 3 | 3 4 | 2 5 | 1 6 | 3 Correlations: cKeyphrase1_kID | cKeyphrase2_kID | cContent 1 | 3 | 0.76 1 | 2 | 0.84 1 | 1 | 4 (my correlations are 'relative' instead of absolute therefore a good correlation often has a value greater than 1 - sorry, not my source data!) Please could you give me a hand creating SQL code for the below tasks?: I think I need an SQL query to: 1. Find kID for the searched for keyphrase 2. Select all records in the JobAdverts table 3. Attach cContent to each record in the JobAdverts table --> (done by finding cContent where kID of the search term = cKeyphrase1_KeyphraseID and JobAdvert_KeyphraseID = cKeyphrase2_KeyphraseID) 4. Sort by cContent DESC Is the below code is close to the correct answer? Is there a way of finding the relevant value for kID and using the value all in the same query, instead of splitting this into 2 queries like below? SELECT kID from Keyphrases WHERE kContent = '$searched_for_keyphrase' # extract result to variable $kID SELECT * from JobAdverts INNER JOIN Correlations ON (Correlations.cKeyphrase1_kID=$kID AND Correlations.cKeyphrase2_kID=JobAdverts.ja_kID) ORDER BY JobAdverts.cContent DESC Many thanks, Stu
×
×
  • 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.