Jump to content

salami1_1

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Everything posted by salami1_1

  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.
  16. yeah correct, I know its not true but I see InnoDB as a different think as when I say Mysql, as MyIsam is standard.
  17. Aaaah thanks! I was using the wrong Fk constraint indeed! Changing product_link with orderlink did the trick! Are you sure Mysql supports Fk? Maybe they can disable that on public hostings? Because tried with; CREATE TABLE ics_newsreactions ( id SMALLINT UNSIGNED NOT NULL auto_increment, postlinkid SMALLINT UNSIGNED NOT NULL, bericht text NOT NULL, datum CHAR(35) NOT NULL, poster_naam CHAR(20) NOT NULL, poster_email VARCHAR(30) NOT NULL, posterip CHAR(16) NOT NULL, active TINYINT(1) UNSIGNED NOT NULL, seckey CHAR(20) NOT NULL, PRIMARY KEY (id) #FOREIGN KEY (postlinkid) REFERENCES ics_news(id); ); (complete other table) but it gave me errors with the foreign key (so commented out now) I'm not using Inno because Inno does not support index and as I'm on shared hosting I need all the efficiency I can get. Best regards,
  18. Hi Guys, I'm working on MySql version: MySQL client version: 4.1.22 Query: SELECT logindb.aantallogs, orderdb.sell_price,orderdb.sell_curr FROM ics_orders orderdb, ics_logins logindb WHERE logindb.product_link = orderdb.id AND gebruikt = 1 ORDER BY logindb.aantallogs ASC Table layout: CREATE TABLE ics_logins ( id SMALLINT UNSIGNED NOT NULL auto_increment, username VARCHAR(40) NOT NULL, pass VARCHAR(40) NOT NULL, aantallogs SMALLINT NOT NULL, gebruikt TINYINT UNSIGNED DEFAULT '0' NOT NULL, type char(15), product_link CHAR(20) NOT NULL, orderlink INT UNSIGNED, PRIMARY KEY (id) ); ALTER TABLE ics_logins ADD INDEX icsLogin_index (username,aantallogs,gebruikt,product_link); #product_link is the unique product_name from product db #orderlink is id from ics_orders (1 to many) CREATE TABLE ics_orders ( id INT UNSIGNED NOT NULL auto_increment, selldatum CHAR(16), cust_email VARCHAR(60) NOT NULL, payp_orderid CHAR(25), cust_name char(100), cust_ip CHAR(16), cust_country CHAR(5), sell_price FLOAT(7,2) NOT NULL, sell_curr CHAR(10) NOT NULL, affiliate char(40), note text, PRIMARY KEY (id) ); ALTER TABLE ics_orders ADD INDEX icsOrders_index (cust_email,cust_country,sell_curr,affiliate); Now in the order table there are 2 currencies EUR and USD (mostly EUR just couple USD) but with the query I only get the results with EUR and not USD.. I checked if perhaps the linking was wrong (mysql doesn't support foreign key so that is not defined in create table statements) but that is all fine. I'm probably doing something wrong but I even took my last semester database design lectures with it but couldn't find the mistake.. If anybody can point me in the right direction? Thanks. Best regards,
×
×
  • 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.