Jump to content

filoaman

Members
  • Posts

    41
  • Joined

  • Last visited

Everything posted by filoaman

  1. Well, thank you all for the answers. First of all i'd like to say that this code is part of a more big and complex script, so finally reading the above answers i try some of the proposes and i manage to get the result i like, but... only when i run this particular part of code as a self-standing script and not as a part of my whole script. Finally after hours of testing and experimentation i found what is the problem: When i manually create the "$string" (term to search), everything works great! But when i create the the "$string" search term, using a 'mysql_query' then the script doesn't work. There is no difference if i create the "$SearchTerms" array using 'mysql_query' or not but the code doesn't work if i extract the "$string" search term using a 'mysql_query'! And of course this is happen ONLY when the search term is with UTF-8 encoding, when i search for ascii terms everything works fine. I give you the 'mysql_query' i use to extract the "$string" search term, for inspection and ideas: $stringArray=array(); $result = mysql_query("SELECT * FROM foo WHERE foo2='foo3' "); while ($row = mysql_fetch_array($result)) { array_push($stringArray, $row["foo4"]); } $string=$stringArray[x]; // where 'x' is the position of the UTF-8 search term i like to use
  2. Hi all I have a very strange situation here... I try to make a string search for a term in utf-8. My search term is "Den lille fløyten" if i use this code: $string = "Den Lille Fløyten"; // The string to search $phrase = "Den lille fløyten"; // The term to search $phrase = preg_replace('/\s+/', '\s+', preg_quote($phrase)); $p = '/\b' . $phrase . '\b/ui'; $result = preg_match($p, $string); // This gives me true (1) everything is OK! But if i put my search term in an array (which i have to do...) and then try to do the search using this search term as an array element i always get false result: $SearchTerms=array('Høstnatt på Fjellskogen', 'Langt Innpå Skoga', 'Den lille fløyten', 'Sølv'); // my array with search terms $string = "Den Lille Fløyten"; // The string to search $phrase = $SearchTerms[2] // The term to search as part of an array $phrase = preg_replace('/\s+/', '\s+', preg_quote($phrase)); $p = '/\b' . $phrase . '\b/ui'; $result = preg_match($p, $string); // This gives me FALSE (0)!!!!!!! Any Ideas? Thanks in advance.
  3. Yes it works. The problem is that i initialize the $str more than once SOLVED
  4. I try this code but i get an empty string... I'm not sure if i express my question clearly. What i want finally is a string like this: $str='<table><tr><td><a href="../../pages/file01.html">File Title 01</a></td><td><a href="../../pages/file02.html">File Title 02</a></td></tr><tr><td><a href="../../pages/file03.html">File Title 03</a></td><td><a href="../../pages/file04.html">File Title 04</a></td></tr><tr><td><a href="../../pages/file05.html">File Title 05</a></td><td><ahref="../../pages/file06.php">File Title 06</a></td></tr><tr><td><a href="../../pages/file07.html">File Title 07</a></td><td><a href="../../pages/file08.html">File Title 08</a></td></tr><tr><td><a href="../../pages/file09.html">File Title 09</a></td><td><a href="../../pages/file10.php">File Title 10</a></td></tr><tr><td><a href="../../pages/file11.html">File Title 11</a></td><td><a href="../../pages/file12.html">File Title 12</a></td></tr><tr><td><a href="../../pages/file13.html">File Title 13</a></td></tr></table>';
  5. Hi friends I use this php code in order to create a simple html table from my data $start = 0; $end = $howmanyItemsOnArray; $split = 2; print "<table><tr>"; for($i = $start; $i < $end; $i++) { print "<td><a href=\"../../pages/".$pagesArray[$i]."\">".$clearPagesArray[$i]."</a></td>"; if(($i) % ($split) == $split-1){ print "</tr><tr>"; } } print"</tr></table>"; After the execution of the script i get this code <table><tr><td> <a href="../../pages/file01.html">File Title 01</a></td><td> <a href="../../pages/file02.html">File Title 02</a></td></tr><tr><td> <a href="../../pages/file03.html">File Title 03</a></td><td> <a href="../../pages/file04.html">File Title 04</a></td></tr><tr><td> <a href="../../pages/file05.html">File Title 05</a></td><td> <a href="../../pages/file06.php">File Title 06</a></td></tr><tr><td> <a href="../../pages/file07.html">File Title 07</a></td><td> <a href="../../pages/file08.html">File Title 08</a></td></tr><tr><td> <a href="../../pages/file09.html">File Title 09</a></td><td> <a href="../../pages/file10.php">File Title 10</a></td></tr><tr><td> <a href="../../pages/file11.html">File Title 11</a></td><td> <a href="../../pages/file12.html">File Title 12</a></td></tr><tr><td> <a href="../../pages/file13.html">File Title 13</a> </td></tr></table> Now what i want to for an application is store this html code to a string. Is this possible? I'm waiting for ideas.
  6. OK - I Did it!!!!!!! My error was that I had to include the (stringData) part on this type of quotes (`stringData`) !!!!!!!!!! Here is the code: $myString="1.32G3.33G0.67G1.66G0.88G9G14.56"; mysql_query("INSERT INTO myDataBase (`stringData`) VALUES ('$myString')"; Thank you for your help
  7. I try this and yes I get an error but without any useful information. This is the error: Query Failed: INSERT INTO myDataBase (stringData) VALUES (1.32G3.33G0.67G1.66G0.88G9G14.56) 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 'stringData) VALUES (1.32G3.33G0.67G1.66G0.88G9G14.56)' at line 1 I'm really stuck.... I don't understand where is the error
  8. I try this, unfortunately doesn't work
  9. Hi friends I'm trying to insert a string into a mysql database. The form of my string is this "1.32G3.33G0.67G1.66G0.88G9G14.56" I select "text" as Type. I put my string on variable $myString="1.32G3.33G0.67G1.66G0.88G9G14.56"; No i'm trying to insert this string to mu database using this code: mysql_query("INSERT INTO myDataBase (stringData) VALUES ('$myString'"); Nothing... What is wrong? Waiting for ideas. Thank you
  10. Great Help thank you. I only had to change some typos. The working code is this $one = array('title1','title2','title3','title4','title5','title6'); $two = array('image1','image2','image3','image4','image5','image6'); $three = array('text1','text','text3','text4','text5','text6'); $numFiles = count($one); $start = 0; $end = $numFiles; $split = 3; print "<table>"; $titles = $images = $texts = ''; for($i = $start; $i < $end; $i++) { $titles .= "<td>".$one[$i]."</td>"; $images .= "<td>".$two[$i]."</td>"; $texts .= "<td>".$three[$i]."</td>"; if(($i % $split) == $split-1){ print "<tr>" . $titles . "</tr><tr>" . $images . "</tr><tr>" . $texts . "</tr>"; $titles = $images = $texts = ''; } } // Just in case the count is not a multiple of the split if (! empty($titles)) { print "<tr>" . $titles . "</tr><tr>" . $images . "</tr><tr>" . $texts . "</tr>"; } print"</table>";
  11. Hi friend I try to create a simple html table and put on every cell data from three arrays my arrays are: $one = array('title1','title2','title3','title4','title5','title6'); $two = array('image1','image2','image3','image4','image5','image6'); $three = array('text1','text','text3','text4','text5','text6'); What i like to create is a table like this: ----------------------------------- | title1 | title2 | title3 | ----------------------------------- | image1 | image1 | image3 | ----------------------------------- | text1 | text2 | text3 | ----------------------------------- | title4 | title5 | title6 | ----------------------------------- | image4 | image5 | image6 | ----------------------------------- | text4 | text5 | text6 | ----------------------------------- In other words i need a script to create a rows take the first 3 data from every array put them on cells and every 3 cells create a new set of rows. Until now i'm able using the following cote to put data from only one array $numFiles = count($one); $start = 0; $end = $numFiles; $split = 3; print "<table><tr>"; for($i = $start; $i < $end; $i++) { print "<td>".$one[$i]."</td>"; if(($i) % ($split) == $split-1){ print "</tr><tr>"; } } print"</tr></table>"; If i use something like this: $numFiles = count($one); $start = 0; $end = $numFiles; $split = 3; print "<table><tr>"; for($i = $start; $i < $end; $i++) { print "<td>".$one[$i]."</td>"; if(($i) % ($split) == $split-1){ print "</tr><tr>"; for($i = $start; $i < $end; $i++) { print "<td>".$two[$i]."</td>"; if(($i) % ($split) == $split-1){ print "</tr><tr>"; } } } } print"</tr></table>"; I get this: ----------------------------------- | title1 | title2 | title3 | ----------------------------------- | image1 | image1 | image3 | ----------------------------------- | image4 | image5 | image6 | ----------------------------------- I know that i'm close but i need some help...
  12. Finally the file_put_contents did the job, thank you kicken. I put all my code on a $data variable and then i store them using the file_put_contents function. Solved!
  13. Thank you for your answers Actually the "$var" was just an example. Right now i try to store something more complex. Let's say that we have 4 different variables $var1, $var2, $var3 and $var4 and the values are 'test', 'foo', '55' and '12345'. When i use php i can echo this: echo "Today I make a ". $var1. " and then ". $var2 . " but finally i get only ". $var3 ." dollars instead of ." $var4; On screen i get this: Today I make a test and then foo but finally i get only 55 dollars instead of 12345 When i try to store it on a file i get the code (1st example). I like to store the 2nd example. Is that possible? Thanks
  14. Hi friends I'm new with php and i want some help. I create a script and everything works OK while the script run on the server. Now what i want is store the code generated from the script on a plain file (txt or html) The problem is that when i try to store the data i get the php scripting on this file. Let's say that i have a variable called "$var" and the value of this variable right now is "12345" I'm looking for a way to store in my txt (or html) file the value of the variable (12345) and not the ($var) like i get right now. Any ideas? I search the net for a couple of hour but since i don't know exactly what i'm looking for is hard to find an answer. Thanks
  15. @jorgepinho Thank you for your answer. I had already visit, read and try examples from the web page you suggest. My problem is that i can't understand where to put this "magic line" $headers = 'Content-type: text/html; charset=utf-8' . "\r\n"; ...and how to use this variable ("$headers"). I try something like this: mail($emailadd, $subject, $text, 'From: '.$emailadd., $headers''); but in this case the mail function don't even send the mail! Can you help me more please with the "4th argument", what do you mean exactly? Thanks
  16. Hello friends. First of all note that i'm just an amateur php programmer, so please if what i ask is very dam don't shoot me... I already search the form and found some solutions to send UTF-8 e-mail message using PHP, but for some reason i have to use the above code. The problem is that this code doesn't send UTF-8 e-mail messages. If you can help me please do it. Thank you <? php $subject = "my subject in UTF-8"; $emailadd = '[email protected]'; $url = "http://www.mySite.com/"; $req = '0'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty. $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 40) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 40 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh charset=utf-8 CONTENT="0; URL='.$url.'">'; ?>
×
×
  • 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.