Jump to content

Highlord

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Highlord's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Oke, I have the following problem. I made a small messagesystem for users, and they can attach a document to the message they send. I can upload the document to a folder on the server. If I open the document straight of the server, its an exact copy of the file I uploaded, which is good and normal. However, when I download the file using the php-page, the file suddenly contains pieces of my php-layout and the original content of the file is at the end of the file I downloaded. I will post the pieces of code that I think are relavant to the problem //get the messages for the logged in user $messages = get_messages($userID); for ($i=0;$i<sizeof($messages);$i++) {     $message = $messages[$i];     echo "<form name=\"frmMessage\" action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\" enctype=\"multipart/form-data\">\n";     echo "<input type=\"hidden\" name=\"userID\" value=\"$userID\">\n";     echo "<input type=\"hidden\" name=\"submitAction\">\n";     echo "<input type=\"hidden\" name=\"fileName\">"; /**Displays the attached file as a link action = download: the action that is being used fileName: the name of the file as it is saved on the webserver (=$message['path'] $message['attachment'] = the name of the original file **/ <a href="javascript: document.frmMessage.submitAction.value='action=download&fileName=<?php echo $message['path']; ?>'; document.frmMessage.submit();">                             <?php echo $message['attachment'];    ?>                                          </a><?php      } if($action == "download")         {                       $path = "C:\attachments/";             $full_file_name = $path.$fileName;             $len = filesize($full_file_name);               $content_type = file_get_mime_type($fileName);             header("Cache-Control: cache, must-revalidate");              header("Pragma: public");             header("Content-Type: " . $content_type);             header("Content-Length: " . $len);             header("Content-Disposition: attachment; filename=\"".$fileName."\";");             header("Content-Transfer-Encoding: binary");             readfile($full_file_name);                       exit;                                   }?> Does anyone know what i'm doing wrong? I think it's the way I link to the file (with the javascript) but I tried with $_SERVER['PHP_SELF']?action=download&fileName= ... also and it just does the same thing. Every help is welcome.
  2. Hi, I have 2 databases with both a table named user in it. first database name is: main Table user: code firstname lastname second database name is: traject table user id (autoincr) code lastname Now I want to read from the first database table all the codes and lastnames and write them to the second database using a PHP-script. I can read all the data, but I cant work in 2 different databases at the same time I think. I make a connection with main, read the data out of user, but then I dont know how to insert those records in the second database. Anyone any idea how to do this?
  3. Going to bump this one last time, hope someone realy has a solution to this.
  4. Ok, I have a XML-file with the following structure: <row> <field name="id">12</field> <field name="car">VW</field> <field name="year">1992</field> <field name="type">4x4</field> <field name="fuel">Gas</field> </row> Offcourse with multipe <row>'s. Now I have to write a PHP-script that gets the id, car, and type out of this structure and assigns it to a variable so i can put this in sql-database table (carid, carname, type). I allready found a way to show the data I want on the screen, I just cant figure out how i get it in the database. This is how I print the selected data on a screen:   <?php       $mblist  = '';     $flag    = false; $type = 0; $hgid = array(); $normid= array(); $perc_code = array();     function openElement($parser, $element, $attributes) {         global $flag;         if (($element == 'field') && ($attributes['name'] == 'id')) { $flag = true; $type = 1; } if (($element == 'field') && ($attributes['name'] == 'car')) { $flag = true; $type = 2; } if (($element == 'field') && ($attributes['name'] == 'type')) { $flag = true; $type = 3; }     }     function closeElement($parser, $element) {         global $flag;         $flag = false;     }     function characterData($parser, $data) {         global $flag,$mblist;         if ($flag)  $mblist[] = $data;     }     $parser = xml_parser_create();     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);     xml_set_element_handler($parser, "openElement", "closeElement");     xml_set_character_data_handler($parser, "characterData");     $document = file_get_contents("lassi.xml");     xml_parse($parser, $document);     xml_parser_free($parser);     foreach ($mblist as $value) {         echo $value.'<br/>';     } ?> I'd realy like some actual help with the scripting and not so much a link to a site or anything, because I've been trying to do this for 2days now and I think I've read every possible site about it, but just dont find how to do it  :(
×
×
  • 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.