Jump to content

KapaGino

New Members
  • Posts

    9
  • Joined

  • Last visited

KapaGino's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Giving td a property of overflow: hidden seems to help, You can then change the height of the second table row to match the width of the track. But I'm not sure if this is exactly what your looking for? http://jsfiddle.net/WH7Kf/27/
  2. Try this one http://jsfiddle.net/Tr3D8/
  3. Hi, I'm trying to grab a particular portion of text from a websites source code using preg_match but I'm not getting a result. <?php $url = "http://www.estatesgazette.com/propertylink/advert/4th_floor_pear_mill_industrial_estate_stockport_cheshire-stockport_cheshire-3383230.htm"; $html = htmlspecialchars(file_get_contents($url)); preg_match('%image-carousel">.+?jpg%i', $html, $match); echo $match[0]; ?> I've tried the pattern in RegExr and it did exactly what I wanted. I'm running PHP 5.4.7 btw. Thanks for any help.
  4. Hiya, I'm trying to learn the basics of XPath but I'm having trouble getting it to return anything. All I want is for it to grab the title of the page and echo it... <?php $doc = new DOMDocument(); $doc->loadHTML("http://www.estatesgazette.com/propertylink/advert/4th_floor_pear_mill_industrial_estate_stockport_cheshire-stockport_cheshire-3383230.htm"); $xpath = new DOMXPath($doc); $nodes = $xpath->query("/html/head/title"); $title = $nodes->item(0)->nodeValue; echo $title; ?> I'm running PHP 5.4.7 btw Thanks
  5. The urls themselves would look like this: http://www.estatesgazette.com/propertylink/advert/blackfriars_road_london-london-3475714.htm http://www.estatesgazette.com/propertylink/advert/borough_high_street_london-london-3476800.htm
  6. Hi there, I've hit a bit of a roadblock on something I've been working on, was wondering if anyone knew of a way to fix the error message: imagecreatefromjpeg():php_network_getaddresses: getaddrinfo failed The code I'm using is below, the script basically grabs a certain image from a set of specific urls and resizes it as close to 600x450 as it can, then saves the image/images in a zip file which the user can then download. I should also mention that I'm currently hosting this on x10hosting, and it runs a-okay locally. <?php include 'zip.php'; function getImage($tags){ $count = 0; foreach ($tags as $tag){ $tag->getAttribute('src'); $count += 1; if ($count == 3){ $old_image = $tag->getAttribute('src'); return $old_image; } } } function deleteFiles($random_name){ $images= scandir("$random_name"); //get an array of files unset($images[0], $images[1]); // loop through files foreach($images as $image){ unlink("$random_name/$image"); // delete each file } rmdir($random_name); } $omitted_urls = []; if (isset($_POST['submit'])){ $start_time = time(); $urls = $_POST['urls']; // take inputted urls $urls = explode("\r\n", $urls); // break them up by a carriage return/new line into array $names = $_POST['names']; // take inputted names $names = explode("\r\n", $names); // break them up by a carriage return/new line into array $random_name = "pics".rand(0,1000); // create a random folder name if (!is_dir("$random_name")){ mkdir("$random_name", 0777); } // for each url for($i=0; $i < count($urls); $i++){ @$html = file_get_contents($urls[$i]); // get the contents of the url $doc = new DOMDocument(); @$doc->loadHTML($html); // load up the html file $tags = $doc->getElementsByTagName('img'); // look for all img tags $count = 0; $special_chars = array('\\','/',':','*','?','"','<','>','|'); // look for any special characters $names[$i] = str_replace($special_chars, "", $names[$i]); // replace them with "" $names[$i] = substr($names[$i], 0, 50); // truncate anything over 50 characters if($old_image = imagecreatefromjpeg(getImage($tags))){ // create the old image echo "The src is ".getImage($tags)."<br>"; $old_width = imagesx($old_image); // get the width of the old image $old_height = imagesy($old_image); // get the height of the old image $ratio_orig = $old_width/$old_height; // work out the ratio of the image $new_width = 600; $new_height = 450; if ($new_width/$new_height > $ratio_orig){ $new_width = $new_height*$ratio_orig; } else { $new_height = $new_width/$ratio_orig; } $new_image = imagecreatetruecolor($new_width, $new_height); // creates a black image to represent size imagecopyresampled($new_image, $old_image, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height); // copy over old image to fit new image imagejpeg($new_image, "$random_name/".$names[$i].'.jpg'); // create the new image file imagedestroy($new_image); // destroy the image file $time = time()- 3600; // find out the time } else { $omitted_urls[] = $names[$i]; } } $final_time = time() - $start_time; // final time is the current time take the starting time $final_time = date("i:s", $final_time); // time taken } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>EGI Research - Resize and Extract Images</title> <link href="/RESEARCH/favicon.ico" rel="shortcut icon" type="image/x-icon" /> <meta name="viewport" content="width=device-width" /> <link href="css/style.css" rel="stylesheet"/> <script src="/RESEARCH/bundles/modernizr?v=rGcoDow97GYrNMSwHq7xCCjlcB3UIY4_OhPRc6BBSQA1"></script> </head> <body> <header> <body> <header> <div class="content-wrapper"> </div> </header> </header> <div id="body"> <section class="featured"> <div class="content-wrapper"> <hgroup class="title"> <h1>URL Image Extractor & Resizer</h1> </hgroup> <?php if(isset($_POST['submit'])){ printf("<br><b> %s images were downloaded and resized in %s seconds </b><br><br>", count(scandir($random_name))-2, $final_time); if (count($omitted_urls) > 0){ foreach($omitted_urls as $omitted_url){ echo "$omitted_url was omitted<br>"; } } createZip($random_name); deleteFiles($random_name); echo "<a href='$random_name.zip'>Click here to download images</a>"; }?> </div> </section> <section class="content-wrapper main-content clear-fix"> <form action="" id="UploadForm" method="post"><div class="validation-summary-valid" data-valmsg-summary="true"><ul><li style="display:none"></li </ul></div> <ol class="round"> <li class="one"> <h5>URLS</h5> <p>Enter a set of EGi URLS</p> <textarea name="urls" rows="4"></textarea> </li> <li class="two"> <h5>File Names</h5> <p> Enter a set of unique identifiable File Names </p> <textarea name="names" rows="4"></textarea> <br> <input type="submit" value="Extract & Resize" name="submit"/><a href="index2.php">Clear Form</a> </li> </ol> </form> </section> </div> <footer> <div class="content-wrapper"> <div class="float-left"> <p>© 2013 - Reed Business Information Ltd.</p> </div> </div> </footer> </body> </html> Thanks for any of your know how.
  7. This is so much cleaner thanks Wow I should really give that page a look, totally didn't know they were dropping it for PDO & MySQLi, thanks a heap for that info.
  8. Hmm, this seems to work fine for me!, this might sound dumb, but I'm a total noob as well xD is the php file you've saved definitely called index.php?
  9. Hi there, I'm trying to make a dynamic website that I can upload poems to and it'll update two sections of the page, one section has the new poems and the other has the top rated poems. I've got it to sort the new poems by date and I know I can get it to sort the poems by the number of likes BUT my way of doing it is potentially messy, and was wondering if any of you know of a more sensible approach? The code is: $query = mysql_query("SELECT * FROM `poems` ORDER BY `time_posted`DESC LIMIT 0, 12"); while($row = mysql_fetch_assoc($query)){ $title[] = $row['title']; $id [] = $row['id']; $time_posted [] = $row['time_posted']; } I store the results of the query into seperate arrays and I then use a while loop embedded in my html code to grab each of the details of the poem, i.e. $title[$x] I know I could copy the same code above and replace $time_posted[ ] with $likes[ ] and then make seperate arrays again but it doesn't seem like the best approach to take. Thanks for any help btw my SQL version is >> 5.5.27
  10. Hi everyone, I started out doing Web Design at College but to be fair the unit was pretty disappointing all we got taught was basic html and everyone just made their website using a WYSIWYG! Uncontent with the course I decided to teach myself the basics of CSS, PHP and MySQL without resorting to the design view of Dreamweaver or Frontpage. I'm now working on a dynamic website that'll let my Sister upload her poems.
×
×
  • 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.