Jump to content

mdub2112

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mdub2112's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Looks like DISTINCT is going to do exactly what I want. THANKS Only problem I have now LOL is trying to figure out how to resolve the [color=red]Trying to get property of non-object in /var/www/html/blablabla on line 34[/color] message I'm getting (line 34 = [color=purple]echo $user['fullname'].' You have access to ' . $uploads_result->num_rows . ' records.'[/color])
  2. The end result I'm looking for is: Client's Name       Record1       Record2       Record3 Client's Name       Record1       Record2       Record3 The query I'm using is [code=php:0]   $uploads_sql = "select *   from user_permissions, uploads, clients   where user_permissions.username = '{$_SESSION['auth_user']}'   and uploads.client = clients.code     and clients.code = user_permissions.company";     $uploads_result = $handle->query($uploads_sql); [/code] [b]The while loop I'm using is[/b] [code=php:0]   while ($uploads = $uploads_result->fetch_assoc()) { echo '<tr><td>'; echo $uploads['client']; echo '</td></tr>'; echo '<tr><td>'; echo $uploads['comments']; echo '</td></tr>'; echo '<tr><td>'; echo 'Download: '."<a href=download.php?id={$uploads['id']}>{$uploads['title']}<br /></a>"; echo '[<a href="delete_record.php?file='.$uploads['id'].'">Delete Record</a>] '; echo '</td></tr>'; } [/code] With that query and code I get: Client's Name Record1 Client's Name Record2 Client's Name Record3 If I change the query to include GROUP BY client, it only shows one record.  How can I go about getting the end result I'm looking for? Sort of a noob here so... Hopefully I've given the info needed to see what I'm doing.
  3. I've got this so it is working with TEXT files; however, not anything else. Is there a setting somewhere that would disallow other types?
  4. I'm basically having the same problem http://www.phpfreaks.com/forums/index.php/topic,117889.0.html However, maybe yours will work better, try this http://www.phpfreaks.com/forums/index.php/topic,95433.0.html
  5. [quote author=kenrbnsn link=topic=117889.msg481279#msg481279 date=1165606013] A few comments on your code, which may or may not have any relevence to your problem. 1) You use the variable "$file" for two different purposes, once as the array holding the results of the qb query and once to hold the actual filename. Change one or the other variable. 2) You have "$dir = opendir($path)", but I don't see where you use the variable anywhere. If you're using Firefox, I would recommend getting either the firebug or livehttpheaders extensions. Either extension will show the headers being returned by your script. Ken [/quote] Ya, I had tried something else, to which is where the opendir came from and I forgot to remove it prior to posting (it's not in the script right now, but no diff).  I am using Firefox, just might have to do that, seems the downloads (when using the headers with readfile or fopen) are getting the correct info as it knows it's a gif, jpg, doc, pdf, zip, etc...    I was wondering about that second occurance of using $file.  I did change that and it didn't seem to help.
  6. [quote author=Caesar link=topic=117889.msg481265#msg481265 date=1165604706] Are you trying to open locally on the server using relative paths? Or are you using absolute paths? Check your php.ini settings for the following value: "allow_url_fopen = On" [/quote] Just checked this...  set to on
  7. Download Link Code [code] echo "<a href=download.php?id={$uploads['id']}>               {$uploads['title']}<br />                 </a>"; [/code] download.php script [code=php:0] <title>Downloading....</title> <link href="../css/emt_external.css" rel="stylesheet" type="text/css"> <div id="global"> <?php include_once('db_depot.php'); $handle = db_connect(); $uploaded = $_REQUEST['id']; $query = "select id, name, type, size from uploads where id = $uploaded"; $result = $handle->query($query);   if (!$result)   {     echo "There was a database error when executing <pre>$query</pre>";     echo mysqli_error();     exit;   }   while ($file = $result->fetch_assoc()) { $file = $file['name']; $type = $file['type']; $size = $file['size']; $path = $file['path']; if(!is_readable($file)) { die("$file does not exist or is not readable"); }   else   { //echo "$filepath is readable and does exist";   header("Pragma: public");   header("Expires: 0");   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");   header('Content-type: ' . $type);   header( "Content-Disposition: attachment; filename=".basename($file));   header( "Content-Description: File Transfer");       header('Accept-Ranges: bytes');       header('Content-Length: ' . $size);   //readfile($file);   $dir = opendir($path);   $handle = fopen($file, 'r') or die('couldnt open file');   $contents = fread($handle, filesize($file)) or die('couldnt read file');   fclose($handle);   echo $contents;   } } exit; ?> </div> [/code] The outcome to this is the same as if I comment out the code below the readfile (to which is now commented out). The files are being uploaded (successfully) to  /var/www/uploads, the path info is stored in the MySQL Dbase.  Currently I have the path stored in one column, and the filename in another with the path attached (/var/www/uploads/filename.ext).
  8. Seems like I have the same problem this gent had http://www.phpfreaks.com/forums/ind...;prev_next=prev Only problem is that when I try to do what resolved his issue, it does open the correct file, only all garbled If I go straight with fopen I get output to the browser like below. e.g. [color=orange][color=red]Low � A Client has a problem to which only affects them and does not affect workflow. An issue of a �Low Severity� would be something to the likes of: �My mouse[/color][/color] is what with a Word Doc [color=orange]��A��1��`��RL�EX�]цX3E��q.4aUC���uJ��pce�G*��k&蒻u]��u�(.A�A����*煃�6B�sNgq77��w�A3`0ウX��5FC�L:���w[/color] is what I get for images If I go with all the headers and then fopen, I get the same results as if I used readfile, to which both seem to not work for me.  With the headers, the file that seems to be sent, is (with a Word file) showing the html head tags in my download.php script. Any help would truly be appreciated.
  9. Can anyone help me with this?
  10. While waiting on hopeful replies, I had done further searching these forums and found a link to that thread. I changed my code to basically match; however, I'm getting the same exact results I had prior. Any other ideas?
  11. OK here's my scenario... I've got an Intranet site to which I have users uploading files to a folder above the docroot via PHP/MySQL. Docroot is /var/www/html Upload folder is /var/www/uploads Once the user fills out the form, of course, items such as id, title, path, file, type, and size are then set in the dbase. That all works. The link I'm using to provide a download link is PHP Code: [code=php:0]echo "<a href='download.php?id={$depot['id']}'>               {$depot['title']}<br />                 </a>";[/code] [b]My download.php script is as follows PHP Code:[/b] [code=php:0]<?PHP include_once('db_depot.php'); $handle = db_connect(); $file = $_GET['id']; $query = "select id, path, file, type, size from depot where id = $file"; $result = $handle->query($query);   if (!$result)   {     echo "There was a database error when executing <pre>$query</pre>";     echo mysqli_error();     exit;   }   if ($file = $result->fetch_assoc())     {     $file = $file['file'];     $type = $file['type'];     $size = $file['size'];     $path = $file['path'];     $filepath = $path . $file;     header('Content-type: ' . $type);     header('Content-Disposition: attachment; filename="' . $file . '"');     readfile($filepath);     } exit; ?> [/code] Now, everything SEEMS to work; however, even though the file download has the correct name, it appears more as if the system is creating a file on the fly using the filename from the dbase instead of sending the file that is in the uploads folder. I'll click a link to download a file that I know is an image and open it up with MS Image Viewer and it comes up with "No preview available". MS Word or Excel files come up all garbled and the only readable information I get from them is the header info. What's Am I doin' wrong? Can I download files from a folder above the docroot? If not, has anyone ever used the database to store the files (don't want the files to get uploaded to a location viewable by everyone as this will eventually go on the web for client use.  Is there anyone that can give me a hand with this?
  12. I'm hoping someone can point me in the right direction. Currently I have a database set up with Users (Id and PW), Group Names, and a table that defines what group users are defined in. Now, I also have another database with employee information (this is all on an internal webserver so...) and I want to use this User\Group\Membership database to hold the credential info.... (hope I'm not losing anyone here). I'm hoping to have the "employee directory" to be available for all to see with the typical info without having to enter in any credentials and then, give the abilty to individuals to be able to update their personal info and only their personal info, yet...this abilty would also be available to the HR Admin...  hopefully this is all understandable. Is there anyone that may be able to point me in the right direction??
  13. First off - NEWBIE here So, where can I find that newbie help forum?? Now, this is all running on a lamp server I've tested w\ both IE and FF and results are same Writer uploads a file (to folder) gives it a title and places it in a category Then publishes the, oh I'll call it a post The dbase holds column names of sop, category (or these are the ones I'm havin' trouble with) Everything seemed to be working fine Output was expected [b]Category 1[/b]   Test 1 Cat 1 [b]Category 2[/b]   Test 1 Cat 2 [b]Category 3[/b]   Test 1 Cat 3 Then I tested the whole thing by adding another 'post' in to a couple of the categories I was hoping for [b]Category 1[/b]   Test 1 Cat 1   Test 2 Cat 1 [b]Category 2[/b]   Test 1 Cat 2   Test 2 Cat 2 [b]Category 3[/b]   Test 1 Cat 3   Test 2 Cat 3 It seems that either the category is not showing the newly added "Test 2 Cat #" or it is kicking out the "Test 1 Cat #" and replacing it with "Test 2 Cat #  Such as [b]Category 1[/b]   Test 2 Cat 1 [b]Category 2[/b]   Test 2 Cat 2 [b]Category 3[/b]   Test 1 Cat 3 Not sure what info you might need other than the code I'm using <?php   include_once('db_grab.php');   $handle = db_connect();   $categories_sql = 'select * from categories order by code';   $categories_result = $handle->query($categories_sql);     while ($categories = $categories_result->fetch_assoc())   {     $sop_sql = "select * from sops                   where category = '{$categories['code']}'                   and published is not null                   order by published desc";       $sop_result = $handle->query($sop_sql);         if ($sop_result->num_rows)     {       $sop = $sop_result->fetch_assoc();       echo "<p class='head'>{$categories['description']}</p>               <p><a href='{$sop['pdf_file']}' target='_blank'>                 {$sop['title']}                 </a>               </p>"; }   } ?> If I change the $sop_sql query to order by title asc (to which I'd prefer) then all categories simply revert back to the first postings Any help greatly appreciated
×
×
  • 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.