Jump to content

antonyfal

Members
  • Posts

    172
  • Joined

  • Last visited

Everything posted by antonyfal

  1. PRogress: It was always downloading the attachments. This morning i opened my download folder and viewed about 100 files that were downloaded through my testing. The download dialog never appeared and the downloads were so small it barely showed up on mozilla.. Anyway this is solved.. All the attempts above work.
  2. I have tried everything even force download and and and ... ive just finished downloading the file to my server and downloading it from there but nothing is working.. I have discovered that i do have the filename fixed though... how can i download a txt file from the server? all my headers are correct.. even if i add the url to the browser the file is displayed on the page and the browser download dialog does not appear.. any ideas? i would like to download the file via jquery ajax..
  3. Hi.. I tried many things to download the files with a .txt extension and spaces in the name, i did manage to get the fix for the spaces in the name of a .txt file name by adding colons.. However now when i try to download files with an .txt file extension, it simply opens the file and does not download it,, regardless whether the name is one word or multiple words... What modification would i have to make to the following code to download .txt files: here is my newly adjusted attempt at downloading the files from server: // this is just the php that i changed $message = base64_decode(imap_fetchbody($imap, $msgnum, $partNum)); $ext = substr($filename, strrpos($filename, '.') + 1); $next = strtolower($ext); $type = "application/octet-stream"; if($next =='asf'){ $type = "video/x-ms-asf"; } if($next =='avi'){ $type = "video/avi"; } if($next =='flv'){ $type = "video/x-flv"; } if($next =='fla'){ $type = "application/octet-stream"; } if($next =='swf'){ $type = "application/x-shockwave-flash"; } if($next =='doc'){ $type = "application/msword"; } if($next =='docx'){ $type = "application/msword"; } if($next =='zip'){ $type = "application/zip"; } if($next =='xls'){ $type = "application/vnd.ms-excel"; } if($next =='gif'){ $type = "image/gif"; } if($next =='jpg'){ $type = "image/jpg"; } if($next =='jpeg'){ $type = "image/jpg"; } if($next =='png'){ $type = "image/png"; } if($next =='wav'){ $type = "audio/wav"; } if($next =='mp3'){ $type = "audio/mpeg3"; } if($next =='mpg'){ $type = "video/mpeg"; } if($next =='mpeg'){ $type = "video/mpeg"; } if($next =='rtf'){ $type = "application/rtf"; } if($next =='html'){ $type = "text/html"; } if($next =='htm'){ $type = "text/html"; } if($next =='xml'){ $type = "text/xml"; } if($next =='xsl'){ $type = "text/xsl"; } if($next =='css'){ $type = "text/css"; } if($next =='php'){ $type = "text/php"; } if($next =='txt'){ $type = "text/plain"; } if($next =='asp'){ $type = "text/asp"; } if($next =='pdf'){ $type = "application/pdf"; } if($next =='psd'){ $type = "application/octet-stream"; } header("Content-Description: File Transfer"); header("Content-Type: $type; name=\"$filename\""); header("Content-Disposition: attachment; filename=\"$filename\""); 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($message)); ob_clean(); flush(); echo $message;
  4. Thanks jairathnem.. if i try to put the $filename in quotes and also encode the $filename.. it does not download, only an image downloads, the text files open for display.. heres what i have tried since posting: header("Content-Description: File Transfer"); header("Content-Type: application/octet-stream"); if(strpos( $_SERVER['HTTP_USER_AGENT'],"MSIE" )>0) { header('Content-Disposition: attachment; filename=" '.urlencode($fileName).' " '); } else { header('Content-Disposition: attachment; filename*=UTF-8\' \' '.urlencode($fileName));// there is something wrong with this part.. } header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); echo $message;
  5. Hi.. I trying to select an attachment from a dropdown select and then i want it to save to the desktop. Everything works perfectly the files all save, however if a file has a name with spaces, the file that saves only take the first word of the name, and the extension is not saved. IE: $filename = amy numbers.txt the file name of the downloaded file is amy and saves without an extension. here is my code: both php and jquery javascript: // here is javascript call <script> jQuery('ul.ligtatchment > li >a.att_dwn').live('click', function (){ jQuery('#loadingdiv').show(); var msg = jQuery(this).attr('rel').split('_'); jQuery.get(globalVar +'&task=em_attachment&msgnum='+msg[0]+'&part='+msg[1]+'&encoding='+msg[2], function(data) { if(data){ jQuery('#atdiv_'+msg[0]).remove(); jQuery('#loadingdiv').hide(); jQuery('<div class="attdiv" id="atdiv_'+msg[0]+'"><iframe id="dnframe_'+msg[0]+'" name="dnframe_'+msg[0]+'" class="dnframe" src="'+globalVar +'&task=em_attachment&msgnum='+msg[0]+'&part='+msg[1]+'&encoding='+msg[2]+'" style="display: none;"></iframe></div>').prependTo('div#chkmldivs'); } else { jQuery('#loadingdiv').hide(); jAlert('ERROR', 'There is no file for download'); } }); }); </script> // here is php code.. $msgnum = $_GET['msgnum']; $partNum =$_GET['part']; $encoding = $_GET['encoding']; $partStruct = imap_bodystruct($imap, $msgnum, $partNum); $filename = $partStruct->dparameters[0]->value; // if i echo the name here it is correct IE: amy numbers.txt //$nfilename = str_replace(' ',' ',$filename); here i tried to replace the blanks with but did not work.. $message = imap_fetchbody($imap, $msgnum, $partNum); switch ($encoding) { case 0: case 1: $message = imap_8bit($message); break; case 2: $message = imap_binary($message); break; case 3: $message = imap_base64($message); break; case 4: $message = quoted_printable_decode($message); break; } header("Content-Description: File Transfer"); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=".$filename); header("Content-Transfer-Encoding: binary"); header("Expires: 0"); header("Cache-Control: must-revalidate"); header("Pragma: public"); echo $message;
  6. RESOLVED IT: if anybody want a function to retrieve all images in a imap html message and convert them to embedded images before they display, so as to avoid Mozilla's warnings regarding http pages on a https domain, here is the code. This code will retrieve any image src, even if the src does not contain a mime type.. IE: http://hi5.taggedmail.com/imgsrv.php?sz=1&uid=5458308947 // here is the curl function to collect the info on the image src url: function get_web_page($url) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => $_SERVER["HTTP_USER_AGENT"], // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } // here is the complete use of the function that will take all the src of the images regardless weather the image has a basename or is a php or html link, it will get the file source and convert it to a base64 embedded image and put it back in its original place.. NOTE: i use output not echo you can change that to your needs.. if(preg_match_all('/<img[^>]+>/i', $msgBody, $matches)){ $i = 1; $imageinfo = array(); foreach ($matches[0] as $img) { $id = 'img_'.($i++); preg_match('/src="(.*?)"/', $img, $m); $src1 = str_replace('src=','',$m[0]); $src = str_replace('"','',$src1); if (preg_match('/(\.jpg|\.png|\.bmp|\.gif|\.jpeg)$/', $src)) { // style and height width attributes are only necessary //for already displayed inline images with correct or direct url's preg_match_all('/(style)=("[^"]*")/i',$img, $imageinfo[$img]); $style = str_replace('"', '', $imageinfo[$img][2][0]); if($Style !='') $nstyle =' style="border: none;'.$style.'"'; else $nstyle=' style="border: none;"'; if(strpos($nstyle,'width')===0 ){ preg_match('/(width)=("[^"]*")/i',$img, $imageinfo[$img]); $width= str_replace('"', '', $imageinfo[$img][2][0]); if($width !='') $nwidth = ' width="'.$width.'"'; } if(strpos($nstyle,'height')===0 ){ preg_match('/(height)=("[^"]*")/i',$img, $imageinfo[$img]); $height= str_replace('"', '', $imageinfo[$img][2][0]); if($height !='') $nheight = ' height="'.$height.'"'; } $type = pathinfo($src, PATHINFO_EXTENSION); $imgData = base64_encode(file_get_contents($src)); $fname = basename($src); $msgBody = str_replace($img, '<img id="'.$id.'" src="data:image/' . $type . ';base64,'.$imgData.'"'.$nwidth.$nheight.$nstyle.'/>', $msgBody); } else { $pic = get_web_page($src); if(!preg_match('/(\.jpg|\.png|\.bmp|\.gif|\.jpeg)$/', $pic['url'])) { $pic = get_web_page($pic['url']); } $type = pathinfo($pic['url'], PATHINFO_EXTENSION); $imgData = base64_encode(file_get_contents($pic['url'])); $fname = basename($pic['url']); $msgBody = str_replace($img, '<img id="'.$id.'" src="data:image/' . $type . ';base64,'.$imgData.'"/>', $msgBody); } } $_SESSION['MessageHTML'] = $msgBody; } else { $_SESSION['MessageHTML'] = $msgBody; }
  7. UPDATE: i have this little function that works on any type of link... the only problem im having now is that is only changes the first image it finds, and doesnt itterate through all the images and changes them.. Can someone see the error with my code? if(preg_match('/<img[^>]+>/i', $msgBody)){ preg_match_all('/<img[^>]+>/i', $msgBody, $matches); $i = 1; $imageinfo = array(); foreach ($matches[0] as $img) { $id = 'img_'.($i++); preg_match_all('/(src|style)=("[^"]*")/i',$img, $imageinfo[$img]); $src= str_replace('"', '', $imageinfo[$img][2][0]); if (preg_match('/(\.jpg|\.png|\.bmp|\.gif|\.jpeg)$/', $src)) { preg_match_all('/(style)=("[^"]*")/i',$img, $imageinfo[$img]); $style = str_replace('"', '', $imageinfo[$img][2][0]); if($Style !=''){ $nstyle =' style="border: none;'.$style.'"'; } else { $nstyle=' style="border: none;"'; } if(!preg_match('/width/i', $nstyle, $iswidth)){ preg_match_all('/(width)=("[^"]*")/i',$img, $imageinfo[$img]); $width= str_replace('"', '', $imageinfo[$img][2][0]); if($width !=''){ $nwidth = ' width="'.$width.'"'; } } if(!preg_match('/height/i', $nstyle, $isheight)){ preg_match_all('/(height)=("[^"]*")/i',$img, $imageinfo[$img]); $height= str_replace('"', '', $imageinfo[$img][2][0]); if($height !=''){ $nheight = ' height="'.$height.'"'; } } $type = pathinfo($src, PATHINFO_EXTENSION); $imgData = base64_encode(file_get_contents($src)); $fname =basename($src); //$msgBody = str_replace($img, '<img id="'.$id.'" src="data:image/' . $type . ';base64,'.$imgData.'"'.$nwidth.$nheight.$nstyle.'/>', $msgBody); } else { $pic = get_web_page($src); //this function returns an array of the image from this type of url: //http://hi5.taggedmail.com/imgsrv.php?sz=1&uid=5458308947 foreach($pic as $k =>$v){ //so here its suposed to run throught the $msgBody and find all images that have this type of link.. and then replace the images in the //image body.. however it does not work, and when it does it only changes the first one it comes accross.. $type = pathinfo($pic['url'], PATHINFO_EXTENSION); $imgData = base64_encode(file_get_contents($pic['url'])); $fname =basename($pic['url']); $nwidth =''; $nheight =''; $nstyle=''; } } $msgBody = str_replace($img, '<img id="'.$id.'" src="data:image/' . $type . ';base64,'.$imgData.'"'.$nwidth.$nheight.$nstyle.'/>', $msgBody); } $_SESSION['MessageHTML'] = $msgBody; } else { $_SESSION['MessageHTML'] = $msgBody; } Regards Antony..
  8. OK! so the code above didn't work for my needs, its only to display the image. I now know that what i have to use is Curl. I have this function which returns the above link as an array of the page at the end of the link.. For the email containing the link above this works fine, however i am looking for a more universal solution to my issue.. function get_web_page( $url ) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } $filename = 'http://hi5.taggedmail.com/imgsrv.php?sz=1&uid=5458308947'; $pic = get_web_page($filename); $srcs = array(); foreach($pic as $k =>$v){ if($k == 'url') $newsrc = $v; print_r($newsrc); } return;
  9. Hi jazzman1. if you google this: "Loading mixed (insecure) display content on a secure page" you can see the changes mozilla made. can you please give an example of how to handle this type of link with my code above? regards Antony
  10. UPDATE: if i use file get_contents on this link: http://hi5.taggedmail.com/imgsrv.php?sz=1&uid=5458308947 i get this output when i echo it: JFIFOcad$Rev: 14797 $ %# , #&')*)-0-(0%()( @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@xx" !"1AQa#q3r2BR$&Db1A2Qa! ?kEP6@ZC@ͻV'Iy,s"n!W]*yspo;V(6 6wsnn0̓r7nPѝ$t Dkr^8.jvMPD.0B N[$}7<ppzzF8R^)~폰~[W`RU!qďXَ`wE <eöVz+F;\ۇL]ܗe975;sP@IIfcTscx#)˧9WxvDfϏWqi/,Jc ُ̃z5g*#ҙM_NZ/wkZ\[W[pr:(6=[ n`QȍM pHM&n2=X17w_4=l qQ5:&.wR1ֹbx$4ؾ7SDxh:Q}/ᚓN8lg !flw8~zCqRs#ilQ9q!a&9kFM]G?htUuc8itR>%kaWu 7',,ƨ U4ƨUrMZjȴ[v:vB:Y(FbdƢ9š+3 pcp月=$/j:H?@\Ny-@Er ߲:.G67jtm1>9RUd]*O77)7/W6BB HzZjWd-Nr\9st ԑԐoM`P,D69!\[$t՘5$]^.-cH1PX|MO c_<V%pgsMTbQvDo` J:|\8"ː:/0QO(6{Yz!nnSyy-6Kޮ-fWӞM~:tFosͥG7?"P-r4nD>`joqR;Whˣ>I $fG5UDsk]X_ԅd~S0$aI-^ I>GBZ86F*p$ƅn@Fd{oq̑ȩC0üV睎^f(bP9t j9Ezk9T_)Kٺ%mJ":`cf8|rX*uMc~__ZV֖T05wUA,ek3,@Å~o7q)g4f<8nA[a`G#N@:M ߞS sSKuF(o;Н1$)M(GqJgFJIx?d{ u-laICqH2S2lLF+Œmssnnܪap9*ߖ6Y(9>Fj٭+f\(xs\;o?IcE0vNc`&hȠqȊN Ay޽B{fO۔a1vo 4ԭQt*ӷ}®F<Ыdu-nۼ`ԿP994 #Y i just want to get this info <img height="" width="" style="" src=""> anyone have any ideas?
  11. Hi there. I am busy creating a php imap app for my site. It was working untill Mozilla changed its policies. No i get this error: Loading mixed (insecure) display content on a secure page "http://hi5.taggedmail.com/imgsrv.php?sz=1&uid=5458308947" div.innerHTML = wrap[1] + elem + wrap[2]; What i am doing now is to fetch the image info such as its height width style, then convert the image to a embedded image and return it to its original spot with its original dimensions and style. However i am having problems with image src's that look like the following example: <img src ="http://hi5.taggedmail.com/imgsrv.php?sz=1&uid=5458308947" />// my regex either //doesn't pick it up, or cannot pull the image from this link.. where as a src link example like the following i have no problems, however it only does the first link <img src ="http://x.tagstat.com/im/headers/default/hi5_logo_small_01.png" /> here is my code: if(preg_match('/<img[^>]+>/i', $msgBody)){ preg_match_all('/<img[^>]+>/i', $msgBody, $matches); $i = 1; $nbody =''; $imageinfo = array(); foreach ($matches[0] as $img) { $id = 'img_'.($i++); preg_match_all('/(src|style)=("[^"]*")/i',$img, $imageinfo[$img]); $src= str_replace('"', '', $imageinfo[$img][2][0]); $style = str_replace('"', '', $imageinfo[$img][2][1]); if($Style !='') $nstyle =' style="border: none;'.$style.'"'; else $nstyle=' style="border: none;"'; if(!preg_match('/width/i', $nstyle, $iswidth)){ preg_match_all('/(width)=("[^"]*")/i',$img, $imageinfo[$img]); $width= str_replace('"', '', $imageinfo[$img][2][0]); if($width !='') $nwidth = ' width="'.$width.'"'; } if(!preg_match('/height/i', $nstyle, $isheight)){ preg_match_all('/(height)=("[^"]*")/i',$img, $imageinfo[$img]); $height= str_replace('"', '', $imageinfo[$img][2][0]); if($height !='') $nheight = ' height="'.$height.'"'; } $type = pathinfo($src, PATHINFO_EXTENSION); $imgData = base64_encode(file_get_contents($src)); $nnsrc = 'data:image/' . $type . ';base64,'.$imgData; $nbody .= str_replace($img, '<img id="'.$id.'" src="'.$nnsrc.'"'.$nwidth.$nheight.$nstyle.'/>', $msgBody); } } else { $nbody = $msgBody; } $_SESSION['MessageHTML'] = $nbody;
  12. Thanks jairathnem and cyberRobot for your reply's. I will look into what you gave me and get back as soon as i have something. regards Antony
  13. Hi.. Im working on a script to invite some one to a live chat/video session.. The people involved are global, from all parts of the world.. How it works: profile "A" stipulates his/her available times, as IE: 13:00pm , 12:00pm, 16:00pm, 19:00pm. (lets say this is a GMT +4 timezone); profile "B" wants to chat to profile "A" and sees the available times to book the appointment to chat.. If profile "B" is in the GMT -4 timezone.. How can i display Profile "A"'s times in profile "B"'s timezone.. if it's 13:00pm in +4 GMT its (totally out of my thumb) 04:00am in profile "B"'s time.. also is php the best way to achieve this? or jquery javascript? i have no code..
  14. Thanks a stack Barand.. This is very helpful and I now know how to use the UNION function.. Awesome..
  15. Hi Barand... (sorry about the Sen :-) ) I got a small spin on my initial query, the two methods above don't work on it.. Could you show me how to use them if i have two WHERE pointing to one Userid? The app is a messaging app, i am trying to collect all the unique user id's from the table under the current users id.. The user1 and user2 columns are the sender and receiver columns, if i make the WHERE only user2 then i will only get users that the current user has sent messages to. I would also like to use the user2 because then i can get get users that have sent messages to the current user.. But i want the rows of users to be unique. My method bellow calls all the users although unique for each user1 and user2 call.. IE: user1: johnny steve user2 johnny steve i want: johnny steve in the table it will look like this: row1: user1=62, user2=30 row2: user1= 29, user2-62 row3: user1=20, user2=62 row4: user1=62, user2= 12 all 62 in user1 column are the messages that 62 sent, all 62's in user2 are messages that 62 received. I am using this information to populate a dropdown (<select name="sendto">options</select>) $query = mysql_query("SELECT DISTINCT global_pm.user1,global_pm.user2,users.id,users.real_name FROM global_pm INNER JOIN users ON users.id IN (global_pm.user1, global_pm.user2) WHERE (global_pm.user2='".$User->id."' and global_pm.id2='1') OR (global_pm.user1='".$User->id."' and global_pm.id2='1')", $ussrLink);
  16. Ta Sen.. Thats exactly what i was looking for... Just off-hand, which is the better method? or does it not make a difference? Regards Antony
  17. Hi thanks for replying.. The thing is i don't know how to write it with the OR or the IN clause.. I cant find an example of where either 1 of two columns match a single column on the other table.. I was hoping someone could write it so i could see the setup or layout of such a query.. basically im trying to avoid the following as it produces duplicates in the dropdown select list.. $msgdropall ='<optgroup label="Contacts online">'; $query2 = mysql_query('SELECT DISTINCT contact.email, users.id, users.real_name FROM contact INNER JOIN users ON contact.email=users.email WHERE contact.userid = '.$thisJRUser->id, $ussrLink); if(mysql_num_rows($query2)>0){ while($row2=mysql_fetch_array($query2)) { $msgdropct .='<option value="'.$row2['id'].'">'.$row2['real_name'].'</option>'; } } else { $msgdropct .=''; } $msgdropall .=$msgdropct; $query3 = mysql_query('SELECT DISTINCT contact.work_email, users.id, users.real_name FROM contact INNER JOIN users ON contact.work_email=users.email WHERE contact.userid = '.$thisJRUser->id, $ussrLink); if(mysql_num_rows($query3)>0){ while($row3=mysql_fetch_array($query2)) { $msgdropdd .='<option value="'.$row3['id'].'">'.$row3['real_name'].'</option>'; } } else { $msgdropdd .=''; } $msgdropall .='</optgroup>'; $msgdropall .=$msgdropdd; $output['MSGDROPALL']=$msgdropall;
  18. Hi. I have a join issue where i need to match either 1 of 2 columns of the first table to a specific column in the second table.. $query2 = mysql_query('SELECT DISTINCT contact.email,contact.work_email, users.id, users.real_name FROM contact INNER JOIN users ON contact.email = users.email', $ussrLink); // here i need a OR option to match either contact.email = users.email (if it does not the i will try the work_email) OR contact.work_email = users.email How can i achieve this..
  19. Hi.. I am working with .csv files. The app allows a user to import contacts into a database table. I would like to prevent duplicates being added under the users id in the table. what i need is a function to make sure that the email in a string does/does not match the email in one of two columns IE: email and work email... here is a simple breakdown of my code.. $nlines = explode("\n",file_get_contents($our_name)); //gets each line from the csv file $arr_head = CSV::get_header_fields( $db, $our_name, 'utf8', $seperators, '"', '\\' ); // custom function to get the first line headers $num = count($arr_head); // count the headers as some data columns do not match the headers columns $nwFile = fopen($new_file, 'w'); $newarray =''; foreach(array_values($nlines) as $value){ $value = str_replace('"', '', $value); $value = str_replace('\'', '', $value); $value = str_replace($seperators, ',', $value); // i have a function that gets the seperator, here i change all to a comma $exists = mysql_query("SELECT email, work_email FROM `contact` WHERE `userid` = '".$User->id."'"); //user id is determined prior while($row=mysql_fetch_array($exists)) { if(strpos(strtolower(str_replace(',',' ',$value)), strtolower($row['email'])) === false && strpos(strtolower(str_replace(',',' ',$value)), strtolower($row['work_email'])) === false) { $nnmu = explode(',', $value); $totnum = count($nnmu); // count the value array to see if it is equal to the headers row. if($totnum == $num){ $newarray .= trim($value).','.$thisJRUser->id."\n"; } else { if (preg_match('/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/si', $value)) // if it is not equal to headers row, we take only rows with emails in it and append the difference in columns to the end of the row. { $nval = $num - $totnum; $valfront = split_nth(implode(',',$arr_head),',', $nval); $string = preg_replace('~[^,]~','',trim($valfront[0])); //here we take the cloumns and remove everything but the comma $newarray .= trim($value).',,'.$string.',,,'.$thisJRUser->id."\n"; // here we add the extra columns to the short value string + 5 extra commas as we are always 5 short :-) it works perfectly.. } } } } } fwrite($nwFile,$newarray); here we write it all to a new csv file named after userid.. fclose($nwFile); problem im having with this function is that it repeats the header row before it shows the second row of data... so i have 2 headers and data.. Can anyone see my error, or have a cleaner solution to this?
  20. Hi.. I have some code that uses the "LOAD DATA LOCAL INFILE" function, the full function works flawlessly. However i use it as a front-end public function for users to import their .csv data into a mysql database.. The function makes use of data mapping to the database. I would like to also set additional cell data to the table to each row added from the "LOAD DATA LOCAL INFILE" function.. IE: the users site id.. HERE IS MY CODE: <pre> $sql = "LOAD DATA LOCAL INFILE '".@mysql_escape_string($this->file_name). "' IGNORE INTO TABLE `".$this->table_name. "` FIELDS TERMINATED BY '".@mysql_escape_string($this->field_separate_char). "' OPTIONALLY ENCLOSED BY '".@mysql_escape_string($this->field_enclose_char). "' ESCAPED BY '".@mysql_escape_string($this->field_escape_char). "' LINES TERMINATED BY '". $this->line_separate_char . "' ". ($this->use_csv_header ? " IGNORE 1 LINES " : "") ."(".implode(",", $fields).") SET `prop_userid` = '".$thisJRuser->id."',`property_uid` = '".$defaultProperty."',`dateadd` = '".CURRENT_TIMESTAMP"'"; </pre> im having problems from this line: <pre> SET `prop_userid` = '".$thisNuser->id."',`property_uid` = '".$defaultProfile."',`dateadd` = '".CURRENT_TIMESTAMP"'"; </pre> could someone show me the correct way to right this last line in.. here is original working code without the SET columns: <pre> $sql = "LOAD DATA LOCAL INFILE '".@mysql_escape_string($this->file_name). "' IGNORE INTO TABLE `".$this->table_name. "` FIELDS TERMINATED BY '".@mysql_escape_string($this->field_separate_char). "' OPTIONALLY ENCLOSED BY '".@mysql_escape_string($this->field_enclose_char). "' ESCAPED BY '".@mysql_escape_string($this->field_escape_char). "' LINES TERMINATED BY '". $this->line_separate_char . "' ". ($this->use_csv_header ? " IGNORE 1 LINES " : "") ."(".implode(",", $fields).")"; </pre>
  21. Hi. I purchased the the adiinviter lisence with one years support about a month ago.. I have not been able to get anyu of the versions of the software to work.. The standalone version 0f the script is where im focused. I have had to make multiple adjustments to get some of the stuff to work, the file imports from multiple email and social networks, csv importer and a manual inviter/importer.. I have managed to gett he manual and csv importer to work.. After several days of pleeding for them to test their software and send me a working version, i have finally had enough.. They have been trying to gain access to my site, my databases and even tried to get remote access to my Laptop.. Why i can only gues.. They have accused me of several things and and and.. They finally fessed that they do not distribute their working versions, they only manually install them.. This is not what i paid for.. If you want to see if you can get it working and null it, PM me and ill send you a copy.. It is the worst software support i have every received.. regards Antony falencikowski
  22. Your solution or hint does not work! and your method of teaching? is questionable.. Some of us learn by the solution and how it was achieved.. here you just threw me in another direction and waisted a day.. and left the scene.. Is there anybody else that can help!!!!!
  23. Hi Im new to "join" function this is my first attempt.. My example below only outputs the first tab/row. I need all the data output.. the "rel" below seems correct to the one tab loaded.. if(isset($_GET['loadLists'])) { if($needAuth == 1 && !is_logged()) return 'you must be logged in to view this list.'; $current_user_id = (__isset('multiuser') == 1)?intval($_SESSION['userid']):0; $q = $db->dq("SELECT * FROM todo_lists INNER JOIN todo_lists_setting ON todo_lists.id=todo_lists_setting.list_id WHERE todo_lists_setting.user_id = '$current_user_id'"); while($row = $q->fetch_assoc($q)) // same as mysql_fetch_assoc { echo '<li id="list_'.$row['id'].'" rel="'.$row['notify'].'_'.$row['showcompl'].'_'.$row['sorting'].'_'.$row['shownotes'].'_'.$row['showdates'].'" class="ytt-tabi"><a href="#list/'.$row['id'].'" rel="'.$row['id'].'" title="'.htmlarray($row['name']).'"><span>'.htmlarray($row['name']).'</span></a></li>'; } }
×
×
  • 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.