Jump to content

hellonoko

Members
  • Posts

    213
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

hellonoko's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. I am trying to write a query that selects all rows entered less than a day ago by comparing the field that states when the row was created against the current date/time minus 1 day. What is the proper way to do this as my query is failing. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/sharingi/public_html/scrape/display/display.php on line 167 <?php $current_time = strtotime("now"); //take one day in seconds from the current time to find the timestamp for 24 hours ago $day_old = $current_time - 86400; //change timetamp to a date format to compare $day_old = date("Y-m-d H:i:s", $day_old); echo $day_old; // select all entries that are less than the 1 day old $query = mysql_query("SELECT * FROM `mp3links` WHERE `foundtime` < $day_old AND `scraped` != '0' ORDER BY `foundtime` DESC"); ?>
  2. I think you would want to use mysql_num_rows() http://au.php.net/mysql_num_rows To count the number of results then compare that to 0-?
  3. Ahhh. Ok so either how I have changed it OR $query1 $query2 so they do not conflict.
  4. I have no idea about classes really but looking at the PHP manual maybe you need to call the class first before you use a function that is part of it? so.. $imgResize = new ImageResize; and then... image_scale or maybe.... $result = $imgResize->{$imageResize->image_scale}(); http://au2.php.net/zend-engine-2.php <? class Foo { public $aMemberVar = 'aMemberVar Member Variable'; public $aFuncName = 'aMemberFunc'; function aMemberFunc() { print 'Inside `aMemberFunc()`'; } } $foo = new Foo; ?> You can access member variables in an object using another variable as name: <? $element = 'aMemberVar'; print $foo->$element; // prints "aMemberVar Member Variable" ?> or use functions: <? function getVarName() { return 'aMemberVar'; } print $foo->{getVarName()}; // prints "aMemberVar Member Variable" ?> Important Note: You must surround function name with { and } or PHP would think you are calling a member function of object "foo". you can use a constant or literal as well: <? define(MY_CONSTANT, 'aMemberVar'); print $foo->{MY_CONSTANT}; // Prints "aMemberVar Member Variable" print $foo->{'aMemberVar'}; // Prints "aMemberVar Member Variable" ?> You can use members of other objects as well: <? print $foo->{$otherObj->var}; print $foo->{$otherObj->func()}; ?> You can use mathods above to access member functions as well: <? print $foo->{'aMemberFunc'}(); // Prints "Inside `aMemberFunc()`" print $foo->{$foo->aFuncName}(); // Prints "Inside `aMemberFunc()`" ?>
  5. I set the code to this: // set the file size $result = mysql_query("UPDATE `mp3links` SET `size` = '$file_size' WHERE `id` = '$update'") or die (mysql_error()); Same exact thing just one line and it worked... any idea why?
  6. They all seem to echo fine. When I include the update it will echo the first row of variables and then the error.
  7. I am using a simple query that I have basically copied from another part of my code where it works perfectly but for some reason I can't see it errors now: <?php // connect the db include_once "connectotron.php"; echo 'updating file sizes...<br>'; $query = mysql_query("SELECT * FROM `mp3links` WHERE `scraped` = '1'"); while ($row = mysql_fetch_array($query)) { $file = '/home2/sharingi/public_html/scrape/scraped/'.$row[sourcefile]; echo $file_size = filesize($file); echo '<br>'; $update = $row[sourcefile]; // set the file size $query = "UPDATE `mp3links` SET `size` = '$file_size' WHERE `sourcefile` = '$update'"; $result = mysql_query($query) or die (mysql_error()); } ?> Error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/sharingi/public_html/scrape/update_sizes.php on line 10 When I comment out the last two lines of my code it works fine listing all the file sizes. Is there something wrong with my update query I cant see? Thanks
  8. I use a glob that scans mp3 directories and sub directories and also checks the file modified time to sort them. I am only up in the maybe 500 mp3s area but it is very quick. Dunno if that gives you any idea.
  9. I have the below simple code that I use to copy remote files. It allows me to copy a file even if its larger than expected or with slower connection as I am copying mp3 and sometimes they are 100megs sometimes 4megs. However when I came across this link: this.bigstereo.net/wp-content/uploads/2009/04/stomp-yo-shoes-bloody-beetroots-remix-the-aston-shuffle-vocal-edit-1.mp3 My script basically hangs although the link is not broken and downloads perfectly. What I have noticed is that the other links load in my browser with quicktime and this link load as a Save As... dialog. Any ideas? Is there a better method I can be using to remotely copy files while still not worrying about the max_execution_time and max_file_size? Thanks. function copyFile($url,$dirname) { $url = str_replace(' ', '%20', $url); //$url = urlencode($url); @$file = fopen ($url, "rb"); if (!$file) { echo "Failed to copy $url !"; return false; } else { //copy file $filename = basename($url); $fc = fopen($dirname."$filename", "wb"); while (!feof ($file)) { $line = fread ($file, 1028); fwrite($fc,$line); } fclose($fc); //echo "File $url saved to PC!"; $time_end = microtime(true); $time = $time_end - $time_start; if ( $time > 60 ) { $time = $time / 60; echo "File: $filename coppied in $time minutes"; } else { echo "File: $filename coppied in $time seconds"; } return true; } }
  10. Hmmm good idea. For now the only error I am getting is on spaces (i think) I can always add str_replaces I suppose. Is there a way I could find out what characters fopen and those functions do not like?
  11. Basically the links are in the DB as links without http:// In whatever format they where crawled from a page in but put into the DB with mysql_real_escape_string(); <?php //get the link to copy from the DB $query = "SELECT * FROM `mp3links` WHERE `scraped` = 0 LIMIT 1"; $result = mysql_query($query); $row = mysql_fetch_array($result) or die (mysql_error()); $url = "http://".$row[link]; $last_slash = strripos( $url ,"/"); $clean_file_name = substr( $url , $last_slash + 1 , strlen($url) ); // do a file copy //$url = "http://www.beachtitti.com/summermix_01.mp3"; $dirname = "/home2/sharingi/public_html/scrape/scraped/"; // close th mysql connection because a large file copy may time out mysql mysql_close($connection); $result = copyFile($url , $dirname); ?> <?php function copyFile($url,$dirname) { //$url = urlencode($url); @$file = fopen ($url, "rb"); if (!$file) { echo "Failed to copy $url !"; return false; } else { //copy file $filename = basename($url); $fc = fopen($dirname."$filename", "wb"); while (!feof ($file)) { $line = fread ($file, 1028); fwrite($fc,$line); } fclose($fc); //echo "File $url saved to PC!"; $time_end = microtime(true); $time = $time_end - $time_start; if ( $time > 60 ) { $time = $time / 60; echo "File: $filename coppied in $time minutes"; } else { echo "File: $filename coppied in $time seconds"; } return true; } } ?>
  12. I need to take care of that first space though also don't I? /audio/Freak You/ Can I apply it to the full link www.whatever.com and then add the http on?
  13. Cool but that makes my links into something like this: http%3A%2F%2Fwww.trashmenagerie.com%2Fmixes%2Faudio%2Fwholesick%2FNOVEMBERMIXTAPE.mp3 And that does not work.
×
×
  • 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.