Jump to content

salami1_1

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

salami1_1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. and if you don't want the newlines at all use: $yourstring = str_replace("\n", "", $yourstring); B.r.
  2. and then I find out that my hosting (Bluehost) doesn't even support this mysql functionality despite the fact they actually pointing me out to an article in THEIR helpdesk database which tells you using LOAD DATA INFILE is very good and fast blablabla ergo, waste of time. humppff time for some dedicated hosting b.r.
  3. yeah I know how that error reporting works.. but I just don't see the error.. aaah I found a way that it works: $sql = "LOAD DATA INFILE '".$tmpfile_lng1_name."' REPLACE INTO TABLE ".$table1." FIELDS TERMINATED BY ';' ENCLOSED BY '\"' LINES TERMINATED BY '\n'"; I tried before without specifying the table columns but then I had ENCLOSED BY '\"' before the word FIELDS which is bad. Now I'm getting access denied error but on my quest of searching for this answer I saw that error passing by multiple times to I'll bet I can find some answer for that using my friend google. thanks
  4. Hi, I've been searching for examples and read the Mysql docs but I just can't see the error: My code: $sql = "LOAD DATA INFILE '$tmpfile_lng1_name' REPLACE INTO TABLE $table1 (id, content, lastupdated) FIELDS TERMINATED BY ';' ENCLOSED BY '\"' LINES TERMINATED BY '\n'"; The file has 1 line atm to test which is: "216";"SRS <span class=blue>forbidden</span>";"2009-01-22 01:01:53"; The file was originally \t delimited and tried that too but same error always. The error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY ' '' at line 1 The query echo'd with the error gives: LOAD DATA INFILE 'credit/en.txt' REPLACE INTO TABLE ics_lng_en (id, content, lastupdated) FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY ' ' as you see the prob is not with the variables the \ and the \n in the query are gone because its echo'd and browser sees them as code. Can anybody help me? Thanks, I've been staring at this for the last 2 days. Best regards, P.s. I also tried LOAD DATA LOCAL INFILE; same error, also tried removing the field ( '(id, content, lastupdated)' )
  5. what you are not telling is that if its a htaccess protected page or just a html login form... but anywayz for htaccess protected page (without curl) you can use this function works as a charm: function getfilecontents($url,$format=0, $user='', $pass='', $referer='') { if (!empty($user)) { $authentification = base64_encode($user.':'.$pass); $authline = "Authorization: Basic $authentification\r\n"; } if (!empty($referer)) { $refererline = "Referer: $this->_referer\r\n"; } $url_info=parse_url($url); $port = isset($url_info['port']) ? $url_info['port'] : 80; $fp=fsockopen($url_info['host'], $port, $errno, $errstr, 30); if($fp) { $head = "GET ".@$url_info['path']."?".@$url_info['query']." HTTP/1.0\r\n"; if (!empty($url_info['port'])) { $head .= "Host: ".@$url_info['host'].":".$url_info['port']."\r\n"; } else { $head .= "Host: ".@$url_info['host']."\r\n"; } $head .= "Connection: Close\r\n"; $head .= "Accept: */*\r\n"; $head .= $refererline; $head .= $authline; $head .= "\r\n"; $content = ""; if(fputs($fp, $head) != FALSE){ while(!feof($fp)) { if(!$content .= fgets($fp,2048)) { return FALSE; } } fclose($fp); return $content; } else{ return FALSE; } } else { return FALSE; } } You might need to edit a little as I copied this function straight out of a class which I made for one of my websites.
  6. After a lot of searching and trying I found the cause and looking at the behaviour I would almost say this is a php bug.. The htmlspecialchars_decode() function is the reason that the 'invisble' newlines are created even when I filter the \n (and \r\n) away with str_replace() before or after doing htmlspecialchars_decode() . The <br /> itself does not cause the newline as I checked for this (sometimes there was a double <br /><br /> and this did NOT cause 2 new lines). Now I have it all working with the following code: $col1 = str_replace("\r\n","", $row['en']); $col2 = str_replace("\r\n","", $row[$taal]); $col1 = str_replace("\n","", $col1); $col2 = str_replace("\n","", $col2); $col1 = str_replace("\t","", $col1); $col2 = str_replace("\t","", $col2); $col1 = str_replace("<","<", $col1); $col1 = str_replace(">",">", $col1); $col2 = str_replace("<","<", $col2); $col2 = str_replace(">",">", $col2); $_SESSION['filedata'] .= $row['blockname']."\t$col1\t$col2\t".nl2br($row['vars'])."\t\n"; Only problem now is that I need to convert all the conversions htmlspecialchars() does, back to normal manually using str_replace(). Which is to say at least very annoying... If anybody has some alternative solution for this or can comment on this problem. Gladly. Best regards,
  7. Hi, My situation is as following: I have some text+html data (html data is encoded htmlspecialchars) in my database. Now some of this data contains newlines. If I go into my phpmyadmin and edit the values manually I can see newlines. Now I want to maintain these newlines as I use them on a part on the website. What I'm trying is to generate a .xls (csv) file but the newlines are screwing with my layout they are create, how obviously, new lines in my excel document which I do not want. My code to solve this atm: $en = htmlspecialchars_decode($row['en'], ENT_QUOTES); $other = htmlspecialchars_decode($row[$taal], ENT_QUOTES); $col1 = str_replace("\r\n","", $en); $col2 = str_replace("\r\n","", $other); $col1 = str_replace("\n","", $en); $col2 = str_replace("\n","", $other); $col1 = str_replace("\l","", $en); $col2 = str_replace("\l","", $other); $_SESSION['filedata'] .= $row['blockname']."\t$col1\t$col2\t".nl2br($row['vars'])."\n"; as you see I attempt to remove all newlines tags but well when I download the file it just doesn work.. I stil lget newlines where I can also find them in the edit boxes in phpmyadmin. Anybody any idea? Best regards,
  8. hmm don't really see any error.. what is the error you receive?
  9. haha no shit thanks! I never knew it was like this I was soo puzzled why it didn't work but this works indeed! thanks problem solved
  10. Hi, I'm trying to display all messages from a database with specific ordering but the ordering isn't working as it should be. Mysql version Server version: 5.0.67-community-log Query: SELECT * FROM ".FEEDBACK." WHERE category_link = '$cat' AND (active = '1' OR ip = '$ip') ORDER BY mstatus,votes,id DESC Table layout: CREATE TABLE ics_feedback ( id SMALLINT UNSIGNED NOT NULL auto_increment, category_link SMALLINT NOT NULL, poster_name CHAR(30) NOT NULL, poster_email CHAR(40) NOT NULL, message TEXT NOT NULL, pdate CHAR(22) NOT NULL, ip CHAR(16) NOT NULL, active TINYINT(1) default '0', votes int(4) default '0', sec_id CHAR(25), mstatus TINYINT(1) default '4', PRIMARY KEY (id) ); ALTER TABLE ics_feedback ADD INDEX feedbackindex (active,category_link); Now I want the last added feedback messages displayed first, but the messages where mstatus is high(er) number should be displayed first (this has bigger priority for the id ordering) and then the messages with the most votes should be displayed first (more priority then the order by ID but less then the 'mstatus'). But when the query is executed, its not giving what I expected. At the moment in the db only 1 message has 1 vote the rest 0. And the mstatus is '3' for 3 messages and 0 for the rest. Now I found that the problem seems to be with the 'mstatus' and 'votes'. If their number is higher they are placed at the end instead of at the beginning. Which is weird because of the number would be higher then the rest it should display at the beginning because of the DESC right? Best regards,
  11. never mind.. after trying a lot I just concluded the DOMPDF is just working very unstable.. At some point I had it working by just altering the HTML files, and then after clicking the link a couple times it suddenly didn't work anymore.. Problem is prob something with caching on the server in combination with caching on client side but its costing to much hassle and time to fix it. I just created PDF's myself now. Best regards,
  12. Hi Guys, I've been struggling with the strangest php behaviour I've ever seen. On my website I have a HTML manual for which I also offer a pdf download link. This PDF is generated on the fly using a opensource application called 'DOMPFD' (http://www.digitaljunkies.ca/dompdf ) Now when I installed it it was working fine but recently I noticed the links were giving me a 500 error. No i've been trying to solve this problem but it behaves very strange. From: http://www.unlocksamsungonline.com/samsungdownloads.php non of the 'pdf' links work they all give 500 error Now when I enter in my browser: http://www.unlocksamsungonline.com/pdfconvert.php?id=6 or http://www.unlocksamsungonline.com/pdfconvert.php?id=7 (this was a testing link) they do work! I tried IE7 and FF3.04 no difference. I did this to check if it had to do with any local caching, apparently not. When I try any of the others (nr 1 - 5) it still gives me an 500 error even when I just enter it manually in the browser. I'm on php5 with FASTCGI enabled thanks in advance
  13. thanks for the explanation, maybe I should switch my stuff to InnoDB then.. I'll have a closer look at that when I have the time. Thanks for the help!
  14. Who told you that? Its not true then? Don't remember exactly where I got that from but read it somewhere.. If its not true then why is the MyIsam always standard? Because in that case it looks like InnoDB is better in every way @ashishag67 yes I also use phpmyAdmin but its not a full solution. PHPmyadmin is not a solution to design databases more for maintaining them.
  15. select your db, select the table then go to 'IMPORT / EXPORT' tab then just browse for your csv and up 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.