Jump to content

dreamwest

Members
  • Posts

    1,223
  • Joined

  • Last visited

    Never

Everything posted by dreamwest

  1. FTP or CURL. Which is faster to transfer files across 2 servers
  2. Im tryinf to go back to pages from where i enter login.php $come_from = $_SERVER['HTTP_REFERER']; if ($come_from == "site.com/login.php"){ $redirect_url = "http://site.com"; }else{ $redirect_url = javascript:history.go(-2); redirect($redirect_url) } I realize javascript shouldnt be there cause it giving an error Parse error: syntax error, unexpected ':' in /home/j
  3. Ok this will get total minuets - before the deliminator ":" $query = "SELECT SUM((length) FROM table"; $result5 = mysql_query($query) or die(mysql_error()); $row5 = mysql_fetch_array($result5); $total_minuets = $row5['SUM(TIME_TO_SEC(length)'] ; echo $total_hours; But how can i get the sum of seconds after the ":"
  4. Ive tried everything to get this to work, but it keeps displaying the same result over and over even though the column has new times added I have a column with time format : 12:50 4:30 1:20 etc... $query = "SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(length))) FROM table"; $result5 = mysql_query($query) or die(mysql_error()); $row5 = mysql_fetch_array($result5); $total_hours = $row5['SEC_TO_TIME(SUM(TIME_TO_SEC(length)))'] * 60 ; echo $total_hours;
  5. Thats where my problem is, i dont know what im searching for to begin with. For this i searched for "Create zip file" results were http://au.php.net/manual-lookup.php?pattern=create+zip+file and a few other search queries
  6. no im really that crap at finding stuff on there I cant understand how i can get a plain file added to an archive. This also get me a fatal error: $zip = new ZipArchive; if ($zip->open('test.zip') === TRUE) { $zip->addFile('/path/to/index.txt', 'newname.txt'); $zip->close(); echo 'ok'; } else { echo 'failed'; }
  7. I searched on php.net for half an hour for this. Thanks
  8. how can i zip a file on my server? http://site.com/files/photo.jpg after zipped http://site.com/files/photo.zip
  9. which ftp function connects to the file so the browser can download it. If i can do it without have to write the file to the main site but direct the file to the browser // define some variables $local_file = 'local.zip'; $server_file = 'server.zip'; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // try to download $server_file and save to $local_file if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) { //send the file to the browser instead of writing it to local server } else { echo "There was a problem\n"; } // close the connection ftp_close($conn_id);
  10. Im trying to create a download file for flv files, this code below displays an onscreen out put but i need to download the file $file = "http://site_2.com/files/video.flv"; header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: private', false); header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="name";'); header('Content-Transfer-Encoding: binary'); header('Content-Length: 20'); readfile("$file"); exit();
  11. I want to use javascript to background proccess a url thats linked to a file http://site.com/files/photo.jpg How can i make the link so it doesnt display the file location <div id="link"> <a href="javascript here">Photo</a> </div>
  12. Im trying to use file exists for a file thats located on another server, the file does exist there but file_exists() function says it doesnt $file = "http://site_2.com/file.jpg"; if (file_exists($file)) { echo 'File found.'; }else{ echo 'File not found.'; exit(); }
  13. Isnt it more flexible? I mean its query based so you can limit, sort etc
  14. $sql = "SELECT customer_user.*, customer_company.* ". "FROM video, customer_company ". "; $result = mysql_query( $sql ); $row = mysql_fetch_array( $result ); if ( $customer_user['phone_number'] == "" ) { echo $row['customer_company.phone_number'] ; }else{ echo $row['customer_user.phone_number'] ; }
  15. class SimpleImage { var $image; var $image_type; function load($filename) { $image_info = getimagesize($filename); $this->image_type = $image_info[2]; if( $this->image_type == IMAGETYPE_JPEG ) { $this->image = imagecreatefromjpeg($filename); } elseif( $this->image_type == IMAGETYPE_GIF ) { $this->image = imagecreatefromgif($filename); } elseif( $this->image_type == IMAGETYPE_PNG ) { $this->image = imagecreatefrompng($filename); } } function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image,$filename,$compression); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image,$filename); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image,$filename); } if( $permissions != null) { chmod($filename,$permissions); } } function output($image_type=IMAGETYPE_JPEG) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image); } } function getWidth() { return imagesx($this->image); } function getHeight() { return imagesy($this->image); } function resizeToHeight($height) { $ratio = $height / $this->getHeight(); $width = $this->getWidth() * $ratio; $this->resize($width,$height); } function resizeToWidth($width) { $ratio = $width / $this->getWidth(); $height = $this->getheight() * $ratio; $this->resize($width,$height); } function scale($scale) { $width = $this->getWidth() * $scale/100; $height = $this->getheight() * $scale/100; $this->resize($width,$height); } function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } } //start code settings $thumbnail_width = 210; $thumbnail_height = 260; $thumbnail_jpeg_quality = 95; $our_file = //image location // resize $image = new SimpleImage(); $image->load("tmp-" . $our_file); // get the size, figure out the proper thumbnail size and create the thumbnail list($original_width, $original_height) = getimagesize("tmp-" . $our_file); if ($original_width > $original_height || $original_width == $original_height) { $image->resizeToWidth($thumbnail_width); } else { $image->resizeToHeight($thumbnail_height); } $image->save("thm-" . $our_file);
  16. Excellent. Works Thanks
  17. I need to tally the SUM from a column that has time format: 00:15 01:38 13:40 etc... This works but when new time are added in seconds the sum of the column doesnt change. $query = "SELECT SUM(time_length) FROM table"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $total_minuets = $row['SUM(time_length)'] * 60; Is it only getting the sum from the first 2 numbers - before the ":"
  18. Do you have the extension stored in the database too? <img src=\"php/content/includes/members_home/user_images/$img.".jpg\" /> also test to see if the image location has a value echo $UsrImgs['ImageLocation'];
  19. http://www.tizag.com/mysqlTutorial/mysqlavg.php
  20. change: echo "<a href=\"photo.php?id=$row[id]\"><img src={$row['file']}/></a><br>"; to echo "<a href=\"photo.php?id=".$row[id]."\"><img src={$row['file']}/></a><br>"; having the way it was would $_GET an id of "$row[id]"
  21. Yes work well. Thanks
  22. How can i convert a number date format to a name based one. All dates are stored as digets in my database: 10-05-2009 and im using a date format to display them in tempates: {$user_details.adddate|date_format:"%d- %m -%Y"} I just need to convert the month to a name, but because the date is stored as a number %F wont work
  23. The url is on another server
  24. I want to make a download link that doesnt link directly to the file but uses a download.php page to get the file. I not sure how to go about it.... Ive got this far : $ID = strip_tags($_GET[id]); $real_location = "http//site.com/files/".$ID.".jpg"; //Fake url location $url = downloadLink($ID); echo "<a href=\"".$url."\">Click here to download file!</a>";
  25. Too much code. But if theres no other way...
×
×
  • 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.