PHP - Unknown Time Remaining (force Download) (read 6 Times)
im using this code:
PHP Code: [Select] Code: [Select] <?php set_time_limit(0); $file = 'test.mp3'; header('Content-Description: File Transfer'); header("Content-Disposition: attachment; filename=\"$file\""); header('Content-Type: audio-x/mp3'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($file)); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Expires: 0'); readfile($file); ?> when downloading i cant see the progress bar. thanks. Similar TutorialsI'm trying to make a code so that it will get the last date and timee it submitted into a database, but for this example I replaced the database loading with a default. I am trying to make it so that it will deisplay how long you must wait until you can vote again, which is every 24hours. $diffrence = strtotime('2010-12-11 10:59:59') - time(); return ("". number_format(($diffrence / 60 / 60), 2) ." hours"); So, lets say the time now is "2010-12-11 20:59:59". 10 hours have passed, so now you have 14 more hours. I wrote a very simple web form that allows my user to view text files from within their Internet browser. I implemented a feature whereby the text files returned by the search are compressed into a ZIP. Here's my code Code: [Select] function getFiles() { $result = null; $ZIPresult = null; if (empty($_POST['DBRIDs'])) { return null; } $mydir = MYDIR; $dir = opendir($mydir); $DBRIDs = $_POST['DBRIDs']; $getfilename = mysql_query("select filename from search_table where rid in (" . $DBRIDs . ")") or die(mysql_error()); while ($row = mysql_fetch_array($getfilename)) { $filename = $row['filename']; $result .= '<tr><td><a href="' . basename($mydir) . '/' . $filename . '" target="_blank">' . $filename . '</a></td></tr>'; $ZIPresult .= basename($mydir) . '/' . $filename; } if ($result) { $result = "<table><tbody><tr><td>Search Results.</td></tr> $result</table>"; shell_exec("zip -9 SearchResult.zip ". $ZIPresult ." > /dev/null "); $fileName = 'SearchResult.zip'; header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Transfer-Encoding: binary"); header('Content-type: application/zip'); header("Content-length: " . filesize($fileName)); header('Content-Disposition: attachment; filename="' . $fileName . '"'); readfile($fileName); } return $result; } It works great If I download the ZIP file from the server using FTP (for example) but I force the download from the page header, the ZIP is corrupted. What am I missing? Thanks for your input. **PS: The new ZipArchive() library/class is not available on our production environment so I chose to use the Unix utility ZIP instead.** Hi, I want to force download an asf (audio) file, i have found a script, but it is not for asf but pdf, i was searching for mime types, but not sure what asf classifies? <?php // your file to upload $file = '2007_SalaryReport.pdf'; header("Expires: 0"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("Content-type: application/pdf"); // tell file size header('Content-length: '.filesize($file)); // set file name header('Content-disposition: attachment; filename='.basename($file)); readfile($file); // Exit script. So that no useless data is output-ed. exit; ?> i found this page http://www.utoronto.ca/web/htmldocs/book/book-3ed/appb/mimetype.html#audi so sould it be audio/x-wav? Thanks, Ted Hello, I have the following code to force download mp3 file. the code is working fine but its only downloading 799 bytes. I am new in php and not able to figure out the problem. please help me to sort it out. thanks. Code: [Select] <?php include "dbconnect.php"; $link=dbconnect(); $cat=$_GET['catagory']; $id=$_GET['id']; $query=("select *from $cat where id='$id'"); $result=mysql_query($query); $row=mysql_fetch_array($result); $file = $row["link"]; header ("Content-type: octet/stream"); header("Content-Disposition: attachment; filename=\"".basename($file)."\";" ); header("Content-Length: ".filesize($file)); readfile($file); exit; ?> Hello, I am trying to subtract the current time from a list of times in a mysql database. The first page inserts the time into mysql.
<?php $var_Time = date("h:i:s"); $mysqli = new mysqli('localhost','root','blah','test'); if ($mysqli->connect_error) { die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error); } $insert_row = $mysqli->query("REPLACE INTO test_table (id, time) Values(NULL, '$var_Time')"); if($insert_row){ while (false); }else{ die('Error : ('. $mysqli->errno .') '. $mysqli->error); } $mysqli->close(); ?>The second page is supposed to iterate through all of the times in the database and subtract the current time, but i cant figure out how to do it. <?php $mysqli = new mysqli('localhost','root','blah','test'); if ($mysqli->connect_error) { die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error); } $query = "SELECT * FROM `test_table`"; $result = $mysqli->query($query) or die($mysqli->error.__LINE__); $var_set_time = stripslashes($row['time']); $var_current_time = date("h:i:s"); $diff = strtotime( $var_current_time .' UTC' ) - strtotime( $var_set_time .' UTC'); echo $diff; ?> Edited by Ch0cu3r, 09 October 2014 - 01:40 PM. Added code tags Hello I already know this is possible with php <?php $file = 'monkey.gif'; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } ?> But I am wondering is it possible to just send over a string of data stored in like $data and create a file clientside (nothing server side). So i'm guessing readfile() has to be replaced with something Hey, So what im trying to do is put my database variables into a session array. So this is what im trying to accomplish... $_SESSION['Name_of_Row'] = $value This is the script I wrote: Code: [Select] Function setupSession(){ session_start(); $query = "SELECT * FROM users WHERE u_id ='{$this->u_id}'"; $result = mysql_query($query); $row = mysql_fetch_array($result); foreach($row as $key => $value){ if(!empty($value)){ $_SESSION[$key] = $value; } } } When that runs I get the following warning. Can anyone tell me what this means and how to fix it? Error: Notice: Unknown: Skipping numeric key 0 in Unknown on line 0 Hello all, I'm collecting date/time information via a form and would like to convert the info into something that I can stick in my MySql database (a timestamp???). I'm collecting the current month (variable name: month-- of the form "mm"), day (variable name: day -- of the form "dd"), year (variable name: year -- of the form "yyyy"), time of day (variable name: time -- of the form "h:00"), and before or after noon (variable name: ampm -- of the form "am" or "pm"). Any suggestions as to how to change this into a quantity that I can store as a value and then use to compare to other date/times would be appreciated. Thanks! Hello,
I try to get website speed of some website, but i can read only ''domain.com'' i can't read website files like css , js ... why ? i use proxies for this job.
here is the php code:
$options = array( 'useragent' => "Firefox (+http://www.firefox.org)", // who am i 'connecttimeout' => 120, // timeout on connect 'timeout' => 120, // timeout on response 'redirect' => 10, // stop after 10 redirects 'referer' => "http://www.google.com", 'proxyhost' =>'85.25.8.14:80' ); $response = http_get("http://solve-ict.com/wp-content/themes/ict%20theme/js/jquery-1.7.1.min.js", $options , $info);but it works fine with http://domain.com/ , but with files css or js it gives 404, using some free proxy servers available ? Thanks.
Basically I would like to place a link on my website and have the user download a file, but rather than just right clicking and choosing save target as, the link must be clicked, on the next page the file is fetched and then the client can download the file. How would I go about setting this up please? Trying to get this done: Page_1 has many external links, when certain links are clicked i do not want user to go directly to page, but rather go to a special add page_2 where user must click a second time on the link to finally get there. The add page_2 must show on screen the name of the initial link from page_1, it must change accordingly with the link it came from page_1,once on page_2 the hyperlink redirects outside the site. So far i am thinking give an id to the div or "<a href..." on page_1 then somehow have page_2 detect that id and fill in the variable for the final external link. Other wise is there a way to detect a url from incoming? I guess a similar example is how some domain name sellers landing page will indicate the name of the site. Such as "Thisdomain.com" is for sale. same landing page but the name changes according to the domain that was typed. Hello, Im making a little script to keep track on how much people have currently earnt on my site. I have everything work but i can't figure out how to work out the current balance At the moment ive got: Code: [Select] $currentbalance = $row['totalpaid'] - $row['points']; Which works untill the points becomes more then the total paid then it starts going in minus. Im sure there's a simple fix but i just can't think of a way. Any help would be great. Thanks hey guys thanks for the upcoming support how do I set the blue to fill up the remaining width of the while maininfo div? I tried setting the width:auto <div class="maininfo"> <div class="large">2</div> <div class="smallblock"> <div class="smalltop">3</div> <div class="small">4</div> </div> <div class="smallblock"> <div class="smalltop">5</div> <div class="small">6</div> </div> </div> .maininfo { width: 600px; } .large { float: left; height: 95px; background-color: blue; width:auto; } .smallblock { float: right; height: 90px; margin: 0 0 0 5px; width: 20%; } .small { background-color: red; height: 50%; width: 100%; } .smalltop { background-color: red; height: 50%; width: 100%; margin-bottom:5px; }Edit fiddle - JSFiddle I have to give credit to user "Psycho" here, who came up with the code I'm using for my Membership Directory. I have even completed all of the code that will allow companies to update their own information in the database when they need to. The last problem I'm having is with my "master" list of members. It is all working with the exception of - I can't get the County heading to show up when the actual County location in the database record is different from the last company. I get the heading properly on the first Company, but after that, even though I know the County data is changing, because I'm echoing out the data as it goes (for testing), and I'm just baffled - I have tried every placement of the IF conditional that I can think of. The current code results can be seen he http://www.nmlta.org..._list-test2.php
I'm sure there is a big clue because my flag that says "Checking County Match" is all occurring before the companies even print out, but I can't find the right change to make in my code, which follows:
// Retrieve ALL the "company" specific data (including contacts) $query = "SELECT company.*, co_contact.cont_name, co_contact.cont_title, co_contact.cont_email FROM company LEFT JOIN co_contact ON company.company_id = co_contact.company_id WHERE company.comp_type = 'Agent' ORDER BY company.comp_county, company.comp_name, co_contact.cont_rank"; $result = $mysqli->query($query) or die($mysqli->error.__LINE__); // Build the $company_array $company_array = array(); while($row = $result->fetch_assoc()) { if(!isset($company_array[$row['company_id']])) { //Add the company specific data here $company_array[$row['company_id']] = array( 'name' => $row['comp_name'], 'uw' => $row['comp_uw'], 'street' => $row['comp_street'], 'pobox' => $row['comp_pobox'], 'csz' => $row['comp_csz'], 'phone' => $row['comp_ph'], 'fax' => $row['comp_fx'], 'web' => $row['comp_web'], 'email' => $row['comp_email'], 'county' => $row['comp_county'], 'branches' => array(), 'br_contacts' => array() ); } //Add the company contact info here $company_array[$row['company_id']]['co_contacts'][] = array( 'name' => $row['cont_name'], 'title' => $row['cont_title'], 'email' => $row['cont_email'] ); } //Run query to get branch info - for ALL companies $query = "SELECT branch.*, br_contact.cont_name, br_contact.cont_title, br_contact.cont_email FROM branch JOIN company ON branch.company_id = company.company_id LEFT JOIN br_contact ON branch.branch_id = br_contact.branch_id WHERE company.comp_type = 'Agent' ORDER BY company.comp_county, branch.br_street, br_contact.cont_rank"; $result = $mysqli->query($query) or die($mysqli->error.__LINE__); //Add branch (and branch contacts) results to $company_array while($row = $result->fetch_assoc()) { $compID = $row['company_id']; $branchID = $row['branch_id']; if(!isset($company_array[$compID]['branches'][$row['branch_id']])) { $company_array[$compID]['branches'][$branchID] = array( 'branch_name' => $row['branch_name'], 'street' => $row['br_street'], 'csz' => $row['br_csz'], 'phone' => $row['br_ph'], 'fax' => $row['br_fx'] ); } $company_array[$compID]['branches'][$branchID]['br_contacts'][] = array( 'name' => $row['cont_name'], 'title' => $row['cont_title'], 'email' => $row['cont_email'] ); } echo "<span class='heading'>"; echo "2014-15 Agent Members of the New Mexico Land Title Association<br><br>"; echo "</span>"; $current_county = 'xxx'; // Start building the table for showing results echo "<table border='1' cellpadding='10' cellspacing='0' style='width:750px; margin-left:100px; margin-bottom:20px'>"; // Begin the "foreach" loop to check for County change foreach($company_array as $company) { echo "<font color='red'>Checking County Match</font><br>\n"; // Enter County IF Statement Here if ($company['county'] != $current_county) { echo "<tr><td><b><font class='county'>"; echo $company['county']," County</font><br><hr></b></td></tr>"; } // Begin the "foreach" loop for rows in the $company_array foreach($company_array as $company) { echo "<tr><td>\n"; $current_county = $company['county']; echo "This company is in $current_county County<br>\n"; echo "<b>{$company['name']}</b><br>\n"; if(!empty($company['uw'])) { echo "<b>{$company['uw']}</b><br>\n";} if(!empty($company['street'])) { echo "{$company['street']}<br>\n";} if(!empty($company['pobox'])) { echo "{$company['pobox']}<br>\n";} echo "{$company['csz']}<br>\n"; echo "{$company['phone']} Fax: {$company['fax']}<br>\n"; if(!empty($company['web'])) { echo "<a href='http://{$company['web']}' target='_blank'>{$company['web']}</a><br>\n";} if(!empty($company['email'])) { echo "Email: <a href='mailto:{$company['email']}'>{$company['email']}</a><br>\n";} // if(!empty($company['county'])) { // echo "Serving <font color='green'>{$company['county']} </font>County<br>\n";} echo "<br>"; foreach($company['co_contacts'] as $co_contact) { if(!empty($co_contact['name'])) { echo "    <b>{$co_contact['name']}</b>, {$co_contact['title']}<br>\n";} if(!empty($co_contact['email'])) { echo "    Email: <a href='mailto:{$co_contact['email']}'>{$co_contact['email']}</a><br>\n";} echo "<br>"; } foreach($company['branches'] as $branch) { echo "    <b>{$branch['branch_name']}</b><br>\n"; echo "    {$branch['street']}<br>\n"; echo "    {$branch['csz']}<br>\n"; echo "    {$branch['phone']} Fax: {$branch['fax']}><br>\n"; if(!empty($branch['email'])) { echo "    Email: <a href='mailto:{$branch['email']}'>{$branch['email']}</a><br>\n";} echo "<br>"; foreach($branch['br_contacts'] as $br_contact) { if(!empty($br_contact['name'])) { echo "        <b>{$br_contact['name']}</b>, {$br_contact['title']}<br>\n";} if(!empty($br_contact['email'])) { echo "        Email: <a href='mailto:{$br_contact['email']}'>{$br_contact['email']}</a><br>\n";} echo "<br>"; } } } echo "</td></tr>\n"; } echo "</table>"; ?>I will greatly appreciate someone pointing out my mistake, which I'm sure is obvious to code gurus - I am just baffled. Thanks! I Have field in my table with max length (10). My data is only (5) characters. ex: "apple" I want to output "apple ". with extra (5) space. Max Length: (10) - (5 characters: apple) = 5 extra white space to be added when outputting fruit. I know can echo it as $row['fruit'] . " "; < == manually, but I want it to be automated based on the number of "max_length" from my field in my table/database. I have made a Php program that downloads an Inno setup installation file for installing a program. However, if I for one or another reason want to make a new download of the same Inno setup installation file, the previous file will still be found in the Download folder. Each of the downloads get a number in parenthesis, setup(1), setup(2), setup(3) etc. However, I wondered if it is posible to erase the previous file in the same process as I download a new one, so that however many downloads I do, there will all the time only be one occurence of this file in the Download folder. The download code is as follows: $exe = "Inno script/Test_setup.exe"; header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"Test_setup.exe\""); header("Content-Length: " . filesize($exe)); readfile($exe); Thanks in advance. Sincerely
Hey im kind of new to PHP me and my mate was working on a script and we can not seem to get this working: Its connected through mysql. And it shows Quote Notice: Undefined index: username in C:\xampp\htdocs\stick_arena.php on line 21 Notice: Undefined index: userpass in C:\xampp\htdocs\stick_arena.php on line 22 Notice: Undefined index: action in C:\xampp\htdocs\stick_arena.php on line 23 Notice: Undefined index: usercol in C:\xampp\htdocs\stick_arena.php on line 24 Notice: Undefined index: stats in C:\xampp\htdocs\stick_arena.php on line 25 Here are the lines Quote // declare variables $username = sanitize($_POST['username']); $password = sanitize(md5($_POST['userpass'])); $action = sanitize($_POST['action']); $usercol = sanitize($_POST['usercol']); $stats = sanitize($_POST['stats']); Here is the full script for that page: Click here please help as soon as possible. Hey, I've got a query in which a variable is interpreted as a column and I don't why this is caused. $upgrade_time_sql = "SELECT * FROM todo_upgrades WHERE profile_id = ".$profile_id." AND level = ".$profile_data['level2_'.$show.'']." AND type = ".$show.""; $upgrade_time_res = mysql_query($upgrade_time_sql) or die (mysql_error()); $show is filled with the content "storage" The mysql_error is "Unknown column 'storage' in 'where clause'" Thanks for helping. im using 000webhost as a test site and when i run this code it redirects me to there err page but with no error message. the sql query works fine in phpmyadmin and i added the rest of the code to try the php side. i "think" the problem is the echo $rows"value's" as im unsure of what the $vars should be <?php include("config.php"); // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql = "SELECT make, COUNT(*) AS total, SUM(IF(comments = \'pass\', 1, 0)) AS withComments FROM dsgi_serval GROUP BY make ORDER BY COUNT(*) DESC"; $result=mysql_query($sql); echo "$sql"; echo "$result"; ?> <table><tr> <td colspan="4"><strong>List data from mysql </strong> </td> </tr> <tr> <td align="center"><strong>make</strong></td> <td align="center"><strong>Total</strong></td> <td align="center"><strong>Validated</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td><?php echo $rows['make']; ?></td> <td><?php echo $rows['total']; ?></td> <td><?php echo $rows['withcomments']; ?></td> </tr> <?php } ?> </table> <?php mysql_close(); ?> |