Jump to content

brosjr

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by brosjr

  1. Hi everyone; The point is, I have a string to break, it contains data and a simple code (//&//) that is exploded to generate an array of values, like: M//&// Neves//&//salas 1 a 6//&// //&// Manual//&// //&// 70165900//&// Bras//&// Text Than I get the $explodedarray: Array ( [0] => M [1] => Neves [2] => salas 1 a 6 [3] => [4] => Manual [5] => [6] => 70165900 [7] => Bras [8] => Text) The problem is, a simple if comparison is not working: if($explodedarray[0] == 'M'){ echo 'yes'; }else{ echo 'no'; } It returns 'no'. Even if I try another comparison like: if($explodedarray[5] == ''){ echo 'yes'; }else{ echo 'no'; } It also returns 'no'. Any idea? Thankx Danilo Jr.
  2. Thank you kicken but that worked just for downloading the pdf as file it didn't help to opening the document on the page. But I thied the below object tag and it worked, not as I expected once I can't handle with it's zoom options, maybe because of encoded strings, but it's fine. <object data='<?php echo data_uri($conta, 'application/pdf');?>' type='application/pdf' width='720' height='900'> </object> Thankx Danilo Jr.
  3. Hi all, On my project some PDF documents and images are storage outside the web public folder, so I just can't reach then just with a simple link and I need to display then on a page. $fileDir = '../data/contas'; For images I use the code below (this solution I found on web): $fileDir = '../data/contas/'; function data_uri($conta, $mime) { $contents = file_get_contents($conta); $base64 = base64_encode($contents); return "data:$mime;base64,$base64"; ) <img src="<?php echo data_uri($conta, 'image/png');?>" width="720"> When I see the HTML code I got <img src="data:image/png;base64,/9j/4AAQSkZJRgABA...(huge amount of string)...FXYq/wD/2Q==" width="720"> and the images are displayed correctly. The problem occurs on PDF files, I use the same function, as follow below and the PDF document is not displaying, there is no error message just a gray background where the document were to be shown. <EMBED SRC='<?php echo data_uri($conta, 'application/pdf');?>#view=FitH,top&toolbar=1&navpanes=0&scrollbar=1&zoom=scale' WIDTH="720" HEIGHT="900" ALIGN="TOP"></EMBED> When I look at the HTML code it shows: <EMBED SRC='data:application/pdf;base64,JVBERi0xLjIK...(huge amount of string)...YK#view=FitH,top&toolbar=1&navpanes=0&scrollbar=1&zoom=scale' WIDTH="720" HEIGHT="900" ALIGN="TOP"></EMBED> Any ideia how can I show the PDF files? Or there is another way to access the files outside web public folder on server to display then? Thankx Danilo Jr.
  4. requinix, The numbers stored on $rest array are already arranged as you sugested, and it does not matter wich number comes first, it only returns the name associated to that first number and not the others. Thank you for the tip, next time I'll not use paraphrased version of the code
  5. Hello all, I had some kind of same problem before and I made very hard changes on the project for that to work, but now I'm experiecing a sort of same problem and I can't change it at all so deep. I have group of number in an array that I explode: array($numbers = explode("|", $rest)); Than I "foreach it": foreach ($numbers as $n=>$num){ $sqlname = mysql_query("select name from table where number = '{$num}'"); $name = mysql_fetch_row($sqlname); echo $num." - ".$name[0]; } The result is: 51.399.517 - Danilo Piva Junior 57.716.524 - 02.067.142 - 51.629.749 - 51.109.841 - 59.852.855 - As it can be seen, the foreach returns each number ($num) holded on the array correctly, but when it need query a value from database it only returns the first value, it does not return each name ($name[0]) as expected. Please Thankx Danilo Jr.
  6. Sorry, the problem occurs when $rscad hold more than one value, not $rsnome. It's like the foreach could only execute once.
  7. Hi everyone, I wrote a script that run correctly on localhost but on server it crachs. The code is: foreach($rscad as $cc=>$contashoje){ array($date = explode("-", $contashoje->vence)); $data = $date[2]."/".$date[1]."/".$date[0]; $pstnome = $conn->query("select nomeconta from tbcontas_nome where idnomeconta = $contashoje->idnomeconta"); $rsnome = $pstnome->fetchAll( PDO::FETCH_OBJ ); $arraydatacad .= "<p style='line-height:120%;'>● <strong>" .$rsnome->nomeconta ."</strong> - R$ " .$contashoje->valor ." com vencimento em " .$data .";"; } On localhost the script works fine and if I ask this code prints the two $rsnome result like: Array ( [0] => stdClass Object ( [nomeconta] => Telefones Oi 0023, 5480 e 5482 ) ) Array ( [0] => stdClass Object ( [nomeconta] => Telefone Oi 6569 ) ) But on server the same script prints the second result as empty: Array ( [0] => stdClass Object ( [nomeconta] => Telefones Oi 0023, 5480 e 5482 ) ) Array ( ) The problem happens when $rsnome has two or more values, when it holds only one value, even on server, the script works correctly. Somebody ? Thanks in advance! Danilo Jr.
  8. Hi all, I wrote a script that put some values into a database, when I look directly at phpMyAdmin it is shown like this Econômica. But when I query this the result comes Econ�mica. I searched all over and I tried the utf8_decode and other ways and nothing, it always changes the portuguese accents with �s. Please Thankx
  9. brosjr

    srtpos?

    Hi everyone, I'm writing a script that uses CURL to capture some data to analise it. While this I have to find a little part of a string in many other strings from an array, so I'm using srtpos, but it's returning strange values. For exemple, when I use the string, like below, it echos "9", and it's ok. $strarray = 'SD55555 |FIL|END|'; $find = 'FIL'; $pos = strpos($strarray , $find); echo $pos; But when I use the same estructure to find the same thing from the array, where $arrayhist[1] = 'SD55555 |FIL|END|', it returns nothing. $strarray = $arrayhist[1]; $find = 'FIL'; $pos = strpos($strarray , $find); echo $pos; Even strange, if instead of 'FIL' I try to find 'SD' it returns "0". And if I try to find just 'D' it also returns nothing. Some clue? :-\ Thankx Danilo Jr.
  10. PFMaBiSmAd, My server has set register_globals as OFF and now everything is working fine! Thank you! Danilo Jr.
  11. PFMaBiSmAd, My server does not allow me to set such feature, but it makes sense once on my wamp localhost the register_globals is set as OFF. I'll check and hope for this solution. Thanks a lot! Danilo Jr.
  12. Hi all, I'm in trouble with a strange problem. At the system login a script sets a $_SESSION['status'], this keeps user status for admin (a), user (u), and so on... In another part of the system I need to post a value also called 'status': <input value="N" type="hidden" name="status"/> and this 'status' value has nothing to do with 'status' session. The problem is that when I post the value 'N' it overwrite the session value, crashing the system then. The most strange is that on the localhost the problem does not happen, it only occurs on the server. Any clue? Thankx Danilo Jr.
  13. denno020, after add the session_start() on the dddl.php page the values were shown fine. Thank you
  14. hi all, I have a form that pass some $_POST values to a page that sets a session like this: session_start(); $_SESSION['TESTE'] = array ($_POST['sexo'],$_POST['nome'],$_POST['senha'],$_POST['senha2'],$_POST['login']); header ("Location: dddl.php"); Then the dddl.php should print the values on this line: print_r ($_SESSION['TESTE']) ; But when i run the application the dddl.php page returns this error: Notice: Undefined variable: _SESSION in C:\Users\Danilo\wamp\www\CNTur\dddl.php on line 2 Why it's not setting or why can't I reach the values? When I run the following code on the same page the session values are returned correctly: session_start(); $_SESSION['TESTE'] = array ($_POST['sexo'],$_POST['nome'],$_POST['senha'],$_POST['senha2'],$_POST['login']); print_r ($_SESSION['TESTE']) ; Thankx Danilo Jr.
  15. Thankx joel24, I'll try to rewrite all the notice errors.
  16. Hi all, I'm having a really strange problem. The application I've been developing isn't running ok on the server I got it hosted. Many select queries just didn't return any values, but on my computer everthing runs perfectly. I developed it using ZendStudio for Eclipse using Wampserver with PHP version 5.2.6., while the server runs the 5.1.6 version. I asked them many times to upgrade but they said it is not the problem. Before the last contact with the support, when I run the application with a PDO::FETCH_OBJ query, the page didn't returned any error message, just got blank. Now they activated some kind of error message service that reports all errors, but now it also reports errors that wasn't. For example, sometimes a page will pass a value like this: "page.php?v=true" and sometimes just not: "page.php". The code has a simple if: if(isset($_GET['v'])){ echo 'imagens/top_arearestrita.jpg'; } else ... Before this message service or on my computer it works fine, but on the server it gives this error: Notice: Undefined index: v in /var/www/html/www/intra/restrito.php on line 72 And it gives this errors for many a many lines, that before was working fine. What is that? Is there a way to activate a king of same service on my computer? And how do I can force a error message to be shown? Actually I use the code below, but it returns a black page: try{ ... }catch (Exception $ex){ echo "Erro: " .$ex->getMessage(); } Thankx Danilo Jr. [attachment deleted by admin]
  17. Hi all, I have this structure of two functions: function get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } function normaliza($text){ function entre($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } foreach (count_chars($text, 1) as $i => $val) { if(chr($i)=='<'){ $totaltag = $val; } } for($u=0; $u <= $totaltag; $u++){ $parsed = entre($text, "<", ">"); $text = str_replace('<'.$parsed.'>',"",$text); } return $text; } The I passed a text named $data throught both functions and I got the correct return: $status = get_string_between($data, 'Inativo', 'CNPJ'); $status = normaliza($status); echo $status.' '; Just after, I passed the same folowing text throught the same both functions: $cnpj = get_string_between($data, 'CNPJ', 'Grau'); $cnpj = normaliza($status); echo $cnpj.' '; And I got this error: Cannot redeclare entre() (previously declared in C:\Users\entidade.php:47) in C:\Users\entidade.php on line 47 Why? I thougth this kind strange because it didin't gave the same error for the function get_string_between. Thanks danilo jr.
  18. Thankx dreamwest and MrAdam, both worked perfectly. The point I was missing was the single slash to set the second value into str_replace: $text = str_replace("/n", '', $text );
  19. Good morning, I passed a bunch of HTML tags over a function that delete then, keeping just the text between. The problem is, after that all the tags were replaced by line breaks. Something like this before the function: <tr> <td> Text </tr> </td> After the function the 4 tags were correctly removed but instead i receive just the string "Text" I receive 2 line breaks, the "Text" and other 2 line breaks, like this: Text In HTML code this line breaks has no tags like <br> or <p> it's just blanck lines. I need to get just the text, how can I get rid of then? I tried this and also didn't work. $text = str_replace("/n", "", $text ); Thanks Danilo Jr.
  20. Hi all, I'm experiencing a problem with the server I am storaging my PHP application. I developed it all based on PDO database access on Zend Studio 6 with 5.2.6 PHP version. The server is running 5.1.6 PHP, so I asked them to update to 5.2.6 because I'm getting the following error message: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) They replied me telling me to use HOST instead SOCKET to access the database. I have searched for a solution and it all seens really confusing, because the queries without PDO return the correct results, but the ones with PDO shows the above message. Other solutions seens to be related to server configuration. A simple update of the server would not solve this, once it runs perfectly on my computer? I really need to rewrite all my application to get rid of all the PDOs? Thankx Danilo Jr.
  21. sasa, I really appreciate your attention. Thank you.
  22. Searching and trying a little bit more, I found a solution that fitted weel for my application: $count = count(explode("<P>", $text)); $pieces= explode("<P>", $text); $t = 0; while ($t < $count){ $teste.= substr_replace($pieces[$t],"<P class=$t>",0,0); $t = $t+1; } echo $teste; Salathe, I'm new on this stuff, and I tryed many solutions before I got this. Thankx Danilo Jr
×
×
  • 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.