Jump to content

mavera2

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Everything posted by mavera2

  1. Thank you for reply. But i need to check for the length of $userList .= $f not $f
  2. I have an array of $fl By using values of this array, i want to create a new string. I need string size will be maximum 200 characters. When i try below code snipped, $f value is added to string two times. How can i add $f to array only one time, with checking size of string. Thank you $fl=getsomelist(); // gives an array $userList=''; foreach ($fl as $f) { if ( strlen($userList .= $f) <= (200) ) { $userList .= $f; } else { break; } }
  3. Not without knowing the context and conditions and values under which it would need to work. What is typically in $userlimit? Is it just the number or is it a longer string of some kind? How is this value being used? Is it in an update query, in which case, you can probably just do it in the query? Is the value (5000) a variable or a fixed number? Just one line of code taken out of context doesn't define a programming problem. Anything we come up with for just that one line would take more statements, but in the overall scheme of what you are doing, once you tell us that, you can probably greatly reduce the number of lines of code. Thank you for reply. $userlimit was a 90-100 character long string. It is used to mention user about his current limit, and limit options. 5000 is a fixed value.
  4. In my codes several times i do this kind of replacement: $userlimit = str_replace('5000','5000+', $userlimit ); Is there a shorter way to do this? I tried this by passing to str_replace by reference. But not worked. Thank you
  5. I'm a beginner. I should debug my code from the webserver. When i use arrays and get some error, i generally make "var_dump" or "print_r" to check my data contents. Most of the time, by echo'ing, i can get the errors with related to structure of arrays etc. But when dumped file is too big, webserver crashes. I use shared hosting, so it becomes problem. For example $html = file_get_html( 'http://www.example.com' ); var_dump($html); I suppose, PHP runs it very long and reserved memory, RAM etc. becomes exhausted. To solve this i sometime write the outputs to txt files. But it would be handy to check the results from browser. What can you recommend me to not to crash server? Thank you
  6. Hmm, the results of query2 are empty strings like [name] =>
  7. Thank you Pikachu for help. No error appears because sql gives results, but false results. query1 gives right results, but the response of the query2 gives results which includes NULL and NOT NULL rows of firstcriteria $firstcriteria='name'; $query1 = "SELECT * FROM mytable WHERE name IS NOT NULL"; $query2 = "SELECT * FROM mytable WHERE '$firstcriteria' IS NOT NULL";
  8. I'm trying to write a query for my MySQL database. I can successfully query the database but something i couldn't did. $firstcriteria='name'; $secondcriteria='age'; $ageMax='30'; $query = "SELECT * FROM mytable WHERE '$firstcriteria' IS NOT NULL AND IF ( '$firstcriteria' = 'mark', 1, ( IF ('$secondcriteria' < '$ageMax', 1, 0) ) ) AND ORDER BY '$secondcriteria' ASC; Where name is not null part: OK and if part: NOT OK I think there is an error of syntax etc. What would be the syntax when we use IF clause in sql queries for MySQL? Thank you
  9. The problem is, in an UTF-8 coded php file, when i join an ASCII coded string with UTF coded string, feed readers show ASCII characters of strings as &#220; &#252; etc.
  10. after some parsing of an outer site, i set the variable $word1 to the obtained string. when i make $word1Encod=mb_detect_encoding($word1); it gives ASCII. i have a string like: $mycomment="başlamış bugün" then $mycommentEncod=mb_detect_encoding($mycomment); it gives UTF-8. when i join them as $joined= $word1 . $mycomment; it gives UTF-8. But the final string has characters like &#252; &#305; which are turkish characters, which are found in variable $word1. Although UTF-8 includes ASCII characters, I tried mb_convert_encoding($word1,"UTF-8","ASCII"); But still it didn't help. My php file's encoding is UTF-8. I tried UTF-8 without BOM, as well. Do you have any recommendation? Thank you
  11. not to reach to cookies. Reaching the contents of the page.
  12. thank you for help xyph. I suppose that i must use javascript to get the member's contents. Then send the data to php server parse it and show it with my interface. Is there some similar example or which commands should i look for. Thank you
  13. i'm sorry but confused.. is it possible with curl() as .josh said or not possible as xyph said ??
  14. That really helped me much ) Thank you for your help and suggestions.
  15. By using twitter api, i'm trying to get latest trends. I need to take trends name and creation time of the list. Can you help me to obtain the values from the array? Thank you This code doesn't work. <?php $jsonurl = 'http://api.twitter.com/1/trends/44418.json'; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json); foreach ( $json_output->trends as $trend ) { echo "{$trend->name}\n"; } ?>
  16. i won't use the member info for myself. i will parse it and show the user with a cleaner interface. you know twitter and facebook provides you with authorizing your application with user's approval. but most of the websites doesn't provide authorizing or apis.
  17. I'm sorry if this is a silly question. When user logins to some other site, he gets a member page. Without login he gets a guest page. I want to write a code that takes member page and parses it, then shows user some parts of it user will select which parts to see. but when i use "file_get_contents", output becomes a guest page, i suppose it is because my php server takes it without user's login data. Is it possible to take member page and parse it ? Because i don't want user to give his login information to my site. Thank you very much for your help.
  18. I couldn't fix this issue for 3 three days, please help me.. code: http://trante.heliohost.org/devrss/yol2.php source: http://trante.heliohost.org/devrss/yol2.txt I want to create an RSS feed to put on my site but i couldn't add it to Google Reader etc. I couldn't validate as well. http://validator.w3.org/feed/ ------------ I take variables from "rssdata.php" file. I set one variable with $mytitle=$arrayPlainText[0]; encoding of $mytitle is ASCII. I use XMLWriter class of php. I set the encoding of xml file as UTF-8 in header. When i open the file in my browser, it shows with no error, but the source code of the output has characters like &#252 &#246.
  19. I'm trying to create an RSS feed. I use following codes. It successfully creates xml feed. $feed->startElement("item"); $feed->writeElement('title', $arrayText[1]); But the output is like this: <title>viyana'da operan&#305;n ortas&#305;ndan ge&#231;en t&#252;rkler</title> I suppose that i should make CDATA for $arrayText[1] but i couldn't figure how.. Thank you.
  20. With the following code i can create an xml file. <?php $myXML = new SimpleXMLElement("<myroot></myroot>"); $title= $myXML->addChild('title'); $title->addAttribute('number','12'); $titleName= $title->addChild('titleName', 'title1'); $titleLink= $title->addChild('titleLink', 'link1'); Header('Content-type: text/xml'); echo $myXML->asXML(); ?> But when i check the validity of xml file http://www.validome.org/xml/validate/ This error occurs: Can not find declaration of element 'myroot'. I suppose that the problem is missing of !DOCTYPE and !ELEMENT lines. How can i create valid XML documents with PHP automatically?? Is it possible to make it without writing doctype and element types for the whole element types of xml by hand $title, $titleName and $titleLink Thank you
  21. I have a php file, call it "mypage.php" it makes come calculations, create 5 different arrays, and creates a table by using the arrays. I found simpleXML to create XMLs easily. I want to make an xml file by using the contents of mypage.php. I want to do that with an argument like that "mypage?type=xml" I'm aware that i should use "$_GET" or "$_POST" But where should i put the php code in page, so when i use argument "xml" it will create an xml file. When i don't give argument it will create an html type file. Or should i use another php that includes mypage.php?? And get arrays from that file? Thank you.
  22. dear jcbones, that really helped me much :) thank you very much
  23. You may need to check and make sure your host has fopen wrappers enabled. As far as i found from google search i run this script. if( ini_get('allow_url_fopen') ) { echo "allo url fopen is OK"; } else { echo "allo url fopen is NOT OK"; } It gave the result OK.
  24. I'm using simple html dom parser. I used it in my web site successfully. But i changed my host company and i can't run my existing codes. "file_get_html" works on some sites. doesn't work on some sites. i couldn't understand the problem. This one works: include_once ('simple_html_dom.php'); $html1 = file_get_html('http://www.yahoo.com'); echo $html1; Although web site can be opened from my browser, This one doesn't work in php script: include_once ('simple_html_dom.php'); $html2 = file_get_html('http://www.eksisozluk.com'); echo $html1; ----------------------------- The same problem occurs again when i use in object oriented way. Works: $html1 = new simple_html_dom(); $address1='http://www.yahoo.com'; $html1->load_file($address1); echo "$html1"; Doesn't work: $html2 = new simple_html_dom(); $address2='http://www.eksisozluk.com'; $html2->load_file($address2); echo "$html2"; The error is: Warning: file_get_contents(http://www.eksisozluk.com) [function.file-get-contents]: failed to open stream: HTTP request failed! in /home/mysite/public_html/myfolder/simple_html_dom.php on line 850 Fatal error: Call to a member function innertext() on a non-object in /home/mysite/public_html/myfolder/simple_html_dom.php on line 1364
×
×
  • 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.