PHP - Extract Information From A Site
Hello I post this message because I am trying to extract information from a site that has the same system of visacentral, I cannot give access to this system because is in a Intranet, but the system is more or less the same that this site:
visacentral.co.uk/ajax/ajax.visaPopup.php?passport_from=BOL&traveling_to[0]=BHS&traveling_for%5B0%5D=T&traveling_to%5B1%5D=&traveling_for%5B1%5D=&traveling_to%5B2%5D=&traveling_for%5B2%5D=&traveling_to%5B3%5D=&traveling_for%5B3%5D=&account_number=BRITTRAV&account_exists=N The problem that I have either I use CURL or file_get_contents then they have a redirection and I cannot get the final content from http://visacentral.co.uk/requirements.php Someone has any idea how this can be done? Thank you very much!! Similar TutorialsI've been trying to get this to work for a few days now and can't seem to get anywhere with it! Any help is very much appreciated. I am creating a number generator where the user is required to insert the maximum number and generate rate. Maximum number is the highest number that the script will go to, and generate rate is how many numbers should be created. When the script runs, the numbers are stored into a MySQL database. The MySQL database creates a unique ID number so it can be recalled at a later date. The user then needs to go to Sorting.php and selects the record they wish to use. The numbers from this record are then counted and then stored into an array. If the numbers 2,5,5,0,2,2,1,3,5,1 where generated, the output of this new array will be: [5] => 3 [3] => 1 [2] => 3 [1] => 2 => 1 (These arrays can be of any length) I now need to extract this data and show it on screen. I don't know how to approach it. Format example: Number 5 appears 3 times Number 3 appears 1 times Number 2 appears 3 times Number 0 appears 1 times Sorting.php <?php $db1 = new Number_Information(); $db1->openDB(); $sql = "select * from GeneratedNumber"; $result = $db1->getResult($sql); if (!$_POST) { //page loads for the first time ?> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> Select the ID (If you have just generated a number, it will be the last one): <!--This is the drop down menu--> <select name="ID"> <?php while ($row = mysql_fetch_assoc($result)) { echo "<option value='{$row['ID']}'> {$row['ID']} </option>"; } ?> </select> <br /> <input type="submit" value="Continue" /> </form> <?php } else { $ID = $_POST['ID']; //This will contain the value that was selected in the drop down menu above. $result = mysql_query("SELECT NUMBERS2 FROM GeneratedNumber WHERE ID='{$ID}'"); //This tells the script to select NUMBERS2 contents which is assosiated with the ID. while ($row = mysql_fetch_array($result)) $NUMBERS2 = $row['NUMBERS2']; echo "$NUMBERS2"; //Testing reasons - remove it later. echo "<br />"; //same as above echo "$ID"; // as above. echo "<br />"; //as above //Convert NUMBERS2 back into an array when inserted into table from Generator.php $NUMBERS = explode(",", $NUMBERS2); // Counts how many times a number appears //******************************************************************************************************************* //IF ALL ELSE FAILS, REVERT BACK TO THIS. //print_r(array_count_values($NUMBERS)); //It will only print the statement, but gives you a good building block when things WILL go wrong. //******************************************************************************************************************* rsort($NUMBERS); print_r(array_count_values($NUMBERS)); (The questions when editing posts are hard. I've needed to Google both of them:() Hello, Anyone know a way I could extract information from YouTube. If I have the URL for the video, how could I get the title, runtime, tags and so on into different strings? url = "http://www.youtube.com/watch?v=kMAI26FPeyM"; Thanks Problem: "Warning: extract() expects parameter 1 to be array, null given in C:\x\xampp\htdocs\pages\user_personal.php on line 32" - error also found on lines 33 and 38. and none of the information is displayed. Goal: I'm trying to retrieve profile information and multiple user inserted pictures and display the pictures through a while loop from one query. <?php $query = 'SELECT u.name_id, i.bio, i.exhib, p.product_code FROM user u LEFT JOIN profile i ON u.name_id = i.name_id LEFT JOIN ecomm_products p ON u.name_id = p.product_code WHERE u.name = "' . mysql_real_escape_string($_SESSION['name'], $db) . '" and p.name = "' . mysql_real_escape_string($_SESSION['name'], $db) . '"'; $result = mysql_query($query, $db) or die(mysql_error()); extract($bio); //line 32 extract($exhib); //line 33 $odd = true; while ($row = mysql_fetch_array($result)) { echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">'; $odd = !$odd; extract($rows); line 38 echo '<td><a href="' . $dir . '/' . $row['product_code'] . '.jpg">'; echo '<img src="' . $thumbdir . '/' . $row['product_code'] . '.jpg">'; echo '</a></td>'; echo '</tr>'; } echo "</table>"; echo "<p>"; ?> <ul> <li>Biography: <?php echo $bio; ?></li> <li>Exhibitions: <?php echo $exhib; ?></li> </ul> I'm trying to build a calculator for a game...but I'm stuck on the extracting part. I don't really know what it's called (so if you know of a tutorial/handbook please link), but how I would I extract this data: //data to extract $name = "Robin hood hat" $currentprice = "3.3m" $change = "+11.5k" //display echo $name echo $currentprice echo $change from: http://itemdb-rs.runescape.com/results.ws?query=robin hood hat And a small question: how would I convert "+11.5k" into "11500" (1k = 1,000)? The * multiplies it but how do I check for and remove the "+" and "k"? Hi, I am very new to PHP and apologies if this question has already been answered in another thread.
I am trying to extract the information from one array into another when some search criteria is matched.
Here is an example array ($original):
Array ( [ 1234567 ] => Array ( [name] => john ) [ 3456 ] => Array ( [name] => johnny ) [ 45673 ] => Array ( [name] => james ) [ 987 ] => Array ( [name] => jamie ) [ 5628721 ] => Array ( [name] => Simon ))
So if I searched for the string john, jo, joh then the new array ($filtered) should be as follows:
Array ( [ 1234567 ] => Array ( [name] => john ) [ 3456 ] => Array ( [name] => johnny ))
I was trying to do this using array_search & preg_match but have been struggling.
Any help would be much appreciated!
I have a website that lists courses. I want each tutor to be able to add a piece of code that will display upcoming courses on their website. I am unsure of the best, secure way to do this. Could I simply create a file with a function and allow the tutor to add this to their site something like: <? include "http://www.mysite.com/showCourses.php?user=peterPan; ?> This showCourses.php would connect and query my database, would this work? This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=321546.0 So I have been working on my website for a while which all is php&mysql based, now working on the social networking part building in similar functions like Facebook has. I encountered a difficulty with getting information back from a link. I've checked several sources how it is possible, with title 'Facebook Like URL data Extract Using jQuery PHP and Ajax' was the most popular answer, I get the scripts but all of these scripts work with html links only. My site all with php extensions and copy&paste my site links into these demos do not return anything . I checked the code and all of them using file_get_contents(), parsing through the html file so if i pass 'filename.php' it returns nothing supposing that php has not processed yet and the function gets the content of the php script with no data of course. So my question is that how it is possible to extract data from a link with php extension (on Facebook it works) or how to get php file executed for file_get_contents() to get back the html?
here is the link with code&demo iamusing: http://www.sanwebe.c...-php-and-jquery
thanks in advance.
So I make a colum in my table called "friends" Is there a way to update using mysql that colum for each user, so let's say friend 1 adds friends 2 with the id of 25 so the query puts the id "25" into the friends column, then if friend 1 adds friend 5 with the id of 26 it puts "26" into the friends column and so on... So it would have like commas in the colum, 25,26,30,31,31 and all those represent the id's of the person who is wanting to add people to his friends list! If so how do I accomplish that, and then what If I want to use mysql to list all those id's and Code: [Select] SELECT name,avatar,etc from userstable WHERE id = "25,26,3,31,31" Is this even possible or am i thinking to harD? Folks, from the below code, i want to extract value of the [template_path] in a Variable. The value that i want to extract is " /home/ae1df/public_html/master/proae2/gdfcart/templates/default-black/". I tired to do $this->template_path but seems not working, Can anyone help please? Here is the Code >>> Savant3_Error: Array ( [code] => ERR_TEMPLATE [info] => Array ( [template] => sidebar-left.tpl ) [level] => 256 [trace] => Array ( [0] => Array ( [file] => /home/ae1df/public_html/master/proae2/gdfcart/includes/template.php [line] => 1298 [function] => __construct [class] => Savant3_Error [object] => Savant3_Error Object ( [code] => ERR_TEMPLATE [info] => Array ( [template] => sidebar-left.tpl ) [level] => 256 [trace] => Array *RECURSION* ) [type] => -> [args] => Array ( [0] => Array ( [code] => ERR_TEMPLATE [info] => Array ( [template] => sidebar-left.tpl ) [level] => 256 [trace] => 1 ) ) ) [1] => Array ( [file] => /home/ae1df/public_html/master/proae2/gdfcart/includes/template.php [line] => 1121 [function] => error [class] => Savant3 [object] => Savant3 Object ( [__config:protected] => Array ( [b][template_path] => Array ( [0] => /home/ae1df/public_html/master/proae2/gdfcart/templates/default-black/ [/b][1] => ./ ) [resource_path] => Array ( [0] => /home/ae1df/public_html/master/proae2/gdfcart/includes/tmpl/resources/ ) [error_text] => template error, examine fetch() result [exceptions] => [autoload] => [compiler] => [filters] => Array ( ) [plugins] => Array ( ) [template] => [plugin_conf] => Array ( ) [extract] => [fetch] => /home/ae1df/public_html/master/proae2/gdfcart/templates/default-black/error.tpl [escape] => Array ( [0] => htmlspecialchars ) ) [banner] => stdClass Object ( [header] => stdClass Object ( [banner] => [count] => 0 ) [left_box] => stdClass Object ( [banner] => [count] => 0 ) [right_box] => stdClass Object ( [banner] => [count] => 0 ) [hometop] => stdClass Object ( [banner] => [count] => 0 ) [homebottom] => stdClass Object ( [banner] => [count] => 0 ) ) [template] => default-black [site] => stdClass Object ( [name] => Paintball Mall [slogan] => This is Master Installation [url] => http://gdfcartophily.co.uk/ [disclaimer] => CERTAIN CONTENT THAT APPEARS ON THIS SITE COMES FROM AMAZON EU SARL. THIS CONTENT IS PROVIDED "AS IS" AND IS SUBJECT TO CHANGE OR REMOVAL AT ANY() Many Thanks [/code] or need to extract all h1 tags and insert into database You can modify this code to make it work? ////////////////////////////////////////////////////////////////// function getTextBetweenTags($tag, $get, $strict=0) { /*** a new dom object ***/ $dom = new domDocument; /*** load the html into the object ***/ if($strict==1) { $dom->loadXML($get); } else { $dom->loadHTML($get); } /*** discard white space ***/ $dom->preserveWhiteSpace = false; /*** the tag by its tag name ***/ $content = $dom->getElementsByTagname($tag); /*** the array to return ***/ $out = array(); foreach ($content as $item) { /*** add node value to the out array ***/ $out[] = $item->nodeValue; } /*** return the results ***/ return $out; } $content = getTextBetweenTags('h1', $get); foreach( $content as $item ) { $h1 = $item.'<br />'; } $query="UPDATE sitis SET hh = '$h1' WHERE id = '$a'"; //My problem and that puts only a h1 regards What is the difference between EXTR_PREFIX_SAME and EXTR_PREFIX_IF_EXISTS? Okay I now have a working extract ZIP archive script. What I am now looking to do is have a loop which checks the percentage complete the extraction is and at 100% (with no erros) carry out a PHP function. The code so far is (and includes comments on how the new function would be placed): $dir = opendir('temp'); while(false !==($file=readdir($dir))){ if(strpos($file, '.zip',1)){ extractupdate($file); } } function extractupdate($file){ $zip=new ZipArchive; if($zip->open('temp/'.$file) == TRUE){ $update=rtrim($file, ".zip"); $zip->extractTo($_SERVER['DOCUMENT_ROOT']."/update/temp/$update"); $zip->close(); echo "Extraction started."; // Place loop here to run untill 100% extraction completed and then run function "intsallupdate($update);" } else { echo "Failed to start extraction."; } } function installupdate($update){ // installupdate() will now shift the files around as necessary. // NB to PHPFREAKS, no assistance with code for installupdate() is required, only the loop. Cheers. } Many thanks in advance. I am new to coding and I am trying to write a simple business registration app. a foreach loop populates a select list and a nested loop checks to see if something new is being added. If so write to the DB. Great. Only part of it is working, I am getting the correct businessId but the categoryId is an array: 188 Array 189 Array 190 Array 191 Array 192 Array 195 Array 196 Array Here is the code: Code: [Select] <form method="post" action="?"> <table> <tr><td class="picklist"><?php echo $pickMessage; ?> <select name="bizCatSelect[]" size="4" multiple> <?php $sql = "SELECT categoryId FROM categories"; $sth = $dbh->prepare($sql); $sth-> execute(); $result = $sth->fetchAll(PDO::FETCH_COLUMN, 0); foreach($result as $value) { if($addRecord == 1) { $selected = false; if(in_array($value, $bizCatSelect)) // $row[1] { $sql = "INSERT INTO businessCat(businessId,categoryId) VALUES(:bizId, :bizCatSelect)"; $sth = $dbh->prepare($sql); $sth->bindValue(':bizId', $bizId, PDO::PARAM_STR); $sth->bindValue(':bizCatSelect', $bizCatSelect, PDO::PARAM_STR); $query = $sth->execute(); $params = array($bizId, $bizCatSelect); // $row[0] $value print_r($params); //$resp = $sth->execute($query, $params); echo "<option selected=\"$value\">$value</option>\n"; // $row[1] $selected = true; } if($selected == false){echo "<option value=\"$value\">$value</option>\n";} } else{ echo "<option value=\"$value\">$value</option>\n";} //echo "<option value=\"$value\">$value</option>\n"; } ?> </select> </td> <td class="addlist"> <table> <tr><td class="formLable">Business Name:</td> <td><input type="text" name="bizName" size="40" maxlength="255" value="<?php echo $bizName; ?>"></td> </tr> <tr><td class="formLable">Address:</td> <td><input type="text" name="bizAddress" size="40" maxlength="255" value="<?php echo $bizAddress; ?>" ></td> </tr> <tr><td class="formLable">City:</td> <td><input type="text" name="bizCity" size="40" maxlength="128" value="<?php echo $bizCity; ?>" ></td> </tr> <tr><td class="formLable">Telephone:</td> <td><input type="text" name="bizTele" size="40" maxlength="64" value="<?php echo $bizTele; ?>" ></td> </tr> <tr><td class="formLable">URL:</td> <td><input type="text" name="bizUrl" size="40" maxlength="255" value="<?php echo $bizUrl; ?>" ></td> </tr> </table> </td> </tr> </table> <p><input type="hidden" name="addRecord" value="1"> <?php if($addRecord == 1) {echo "<p><a href=\"?\">Add another business</a></p>";} else {echo "<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Add Business\">";} ?> </p> </form> I just can't seem to get this last part, any suggestions? AL I can t seem to get this. I need to extract some data from the following xml file. http://api.twitter.com/1/users/show/seobpo.xml I just want to get seobpo's tweet count. The data will be used in a wordpress blog. Thank you Hi, I got 1 warning form the server, It said:
Warning: extract() expects parameter 1 to be array, null given in /home/tz005/public_html/COMP1687/edit.php on line 113
extract($row);
how to fix the warning,should I replace it with extract($array);?
http://www.abc.com/sports/more/others/Younger-people/show/7321382.xml http://www.abc.com/news/head/Elder-people/show/7321302.xml In the above string,please tell me how to extract the portion, and store "sports/more/others" and "news/head" in another string. Folks, Quote http://natty.com/p/bh-fitness-class-indoor-magnetic-exercise-bike-2-years-parts-/detail/b004r2wuak/fitness-spinning.html From this url String, i want to extract the last part of string which is, "fitness spinning". This URL is dynamic an can have any value in that last bit, so how to extract anything btween Two Forward slashes just before .html? Note: It can not be extracted with GET as its not how its designed. Thanks Natasha Hi, how do I extract a substring? I just want to store "car" in a variable for other uses: Here is the original string: car/red/blue/gun/hit Any help much appreciated! Hello, I am creating zip file of multiple files using PHP and downloading it. Problem is that: zip file is getting extracted by only WinRAR, its not getti ng extracted by default windows extracter or other software. Here is code which I have written -
$file_folder = 'referral-resume/'; |