Jump to content

phdphd

Members
  • Posts

    248
  • Joined

  • Last visited

Everything posted by phdphd

  1. Hi Kicken, Thank you for your quick reply and solution. However, as shown below I enclosed the div section between the html "body" tags to make P a child of Body and it still does not work. <html> <head> <title>Untitled</title> <style type="text/css"> .has-js .hide-if-js { display: none; } </style> <script type="text/javascript"> //Use jquery to run a function on dom ready and add the has-js class. $(function(){ $('body').addClass('has-js'); }); </script> </head> <body> <div> <h1>Some title here</h1> <p class="hide-if-js">blah blah blah</p> </div> </body> </html> I am quite new to JS. There must be something obvioulsy wrong/missing to gurus that I am still not aware of . I would much appreciate your help again. Thanks.
  2. Here is the complete code. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Display/Hide div in javascript</title> <script> function display_hide(id) { if(document.getElementById(id).style.display=="block") { document.getElementById(id).style.display="none"; document.getElementById('button_'+id).value='+'; } else { document.getElementById(id).style.display="block"; document.getElementById('button_'+id).value='-'; } return true; } </script> <noscript><style>donotdisplay { display:none; }</style></noscript> </head> <body> <br />Title1<donotdisplay> <input type="button" id="button_text1" onclick="javascript:display_hide('text1');" value="+" /></donotdisplay><div style="display: none" id="text1" > Detailed info related to title1</div><br />Title2<donotdisplay> <input type="button" id="button_text2" onclick="javascript:display_hide('text2');" value="+" /></donotdisplay><div style="display: none" id="text2" > Detailed info related to title2</div><br />Title3<donotdisplay> <input type="button" id="button_text3" onclick="javascript:display_hide('text3');" value="+" /></donotdisplay><div style="display: none" id="text3" > Detailed info related to title3</div><br />Title4<donotdisplay> <input type="button" id="button_text4" onclick="javascript:display_hide('text4');" value="+" /></donotdisplay><div style="display: none" id="text4" > Detailed info related to title4</div> </body> </html> I tried to use a <noscript></noscript> tag with some php in it to clear style="display: none" but this does not work. Thanks
  3. Hi All, I have a series of titles to which detailed info is associated, as well as a button that allows to display this info, then to hide it. By default, detailed info is hidden. The problem is that if javascript is disabled, only the titles display, with no means for the user to display detailed info. I would like detailed info to display by default if JS is not enabled on the user's PC. I unsuccessfully tried to find a way to automatically modify the 'display:none' setting of the div section of the detailed info when JS is disabled. Thanks for you help.
  4. Hi All, I found a statement in a forum that enables to send an array via mail. mail($to, $subject, print_r($array, 1), $headers); The problem is that all the key/value pairs appear in a single line. I would like them to appear in seperate lines. (One solution could be adding a '<br />' at the end of each value, but I do not know how to do that with multidimensional arrays.) Thanks.
  5. Hi All, After reading over your answers, I got to the following solution, that tests both export to db and import from db. Hope it helps other newbies like me . if (isset($_POST['user_input'])) { $user_input=$_POST['user_input']; $link = @mysql_connect('localhost', 'root', ''); $user_input=mysql_real_escape_string ($user_input); mysql_select_db('textareachl', $link); $insert_textarea_into_db_field='INSERT INTO `textareachl`.`textarea` (`text`) VALUES (\''.$user_input.'\')'; $rs = mysql_query($insert_textarea_into_db_field, $link); $sql = 'SELECT * FROM textarea Where text="'.$user_input.'"'; $rs = mysql_query($sql, $link); $arr = mysql_fetch_array($rs); $txt =$arr['text']; echo '<br />Retreiving from DB into textarea '; echo '<br /><textarea name="text" cols="100" rows="15" >'.$txt.'</textarea>'; } Thanks again to all of you.
  6. Well, Christian, you must be right somewhere. I was just writing the following when you sent your post I noticed in my session variables that before sending data to db, linebreaks appear as "\\r\\n". I think this is due to a mysql_real_escape_string processing in my code. So I solved the issue using the statement : $txt = str_replace("\\r\\n", "\r\n", $txt); now text appears correctly laid out in the textarea. Thanks to all of you.
  7. Thanks for your reply. However, for "cosmetics" reasons, I want the text to appear as the user initially wrote it, with the same layout, and without "\r\n". If it works from a manually set variable, then there is no reason why it should not from a text retreived from a database.
  8. Hi All, I am facing an issue I cannot solve and I just do not understand why. In a db table, I've got a field that contains text coming from a textarea in a form. If the user had entered breaklines to divide their text into paragraphs, the breaklines are replaced with "\r\n" strings, so the text in the table field may look like "Hello\r\nHow are you?". This works. Now, assuming that the user wishes to edit that text, I want to retreive that text into a textarea, with the same paragraph layout as that initially used by the user. Here is my code (without the whole db error checking code) : $link = @mysql_connect('localhost', 'root', ''); mysql_select_db('mydb', $link); $sql = 'SELECT * FROM table_name Where field_id="31"'; $rs = mysql_query($sql, $link); $arr = mysql_fetch_array($rs); $txt =$arr['user_input']; $txt = nl2br($txt); echo '<br />retrieved text from db is ' .$txt.'<br />';//Will display "retrieved text from db is Hello\r\nHow are you?" $txt=str_replace("<br />", "", $txt); echo '<br /><textarea name="text" cols="100" rows="15" >'.$txt.'</textarea>';// Will display "Hello\r\nHow are you?" in the textarea Now if manually set a variable called "Hello\r\nHow are you?". The following code $string = "Hello\r\nHow are you?"; $string=nl2br($string); $string=str_replace("<br />", "", $string); echo '<br /><textarea name="text2" cols="100" rows="15" >'.$string.'</textarea>'; Will generate "Hello How are you?" in the textarea. Why can't I manage to make this work with the text retreived from the database ? Thanks for your help. Phd
  9. Thanks all of you for your answers. My PHP code never sets a value for the ID field. It fills only the other fields. Basically the code puts all the data entered by the user in an array where keys are named according to the field names in the DB table, then it builds the insert condition by simulating SQL language and by using array key names as table fields and array values as the table values to be inserted. Should the query fail for any reason (no connection to server/database, wrong table name/field, etc.), and since my website is still under development, typical PHP error messages display. There are anyway no automatic retries in my php code, since it is designed to stop running in such situations and to display a message to the user. Definetely not enough to account for the values skipped. For example, the autoinc counter jumped from 2000203 directly to 9999999 while just a few minutes/hours elapsed between the 2 inserts. I never manually tested 7 millions queries in the meantime, and my code is not designed to do that automatically anyway. All header instructions are followed by exit() instructions. All in all I just wonder whether the "guilty" is not the ZEROFILL setting. It is very strange that the autoinc counter jumped from 2000203 to 9999999. I have the feeling that if I had chosen INT(12) instead of INT (7), it would have jumped from 000002000203 to 999999999999.
  10. Thank you for your answer. Here are my comments. The insert SQL/PHP instruction does not set the ID table field. Basically I have an array containing data gathered from a form like name, address, zip code, city, etc. Then I send this data to the table, each piece in the corresponding field, and let the database set the value in the ID field. I do not insert data massively. And should data already exist in the DB there would be no conflict because I test (SELECT) whether data exists before sending (INSERT) it to the DB. No such a risk yet , my website is still under development on my PC.
  11. Hi All, I defined an autoincrement ID field with 7 digits (int(7) ZEROFILL), so as to get 0000001, 0000002, 0000003, etc., enough for the table to contain as many as 10 000 000 rows. At the beginning all was OK. Then I noticed that the field would "skip" entire ranges. For example, it would directly go from 0000100 to 0000200. Things became very complicated when it went directly to 9999999, which is the last value allowed by int(7), because the next time it set the "10000000" value, which contains 8 digits, whereas it had so far used only 99.9999% of the values available with int(7). The problem is that I really need an 7-digit format for this field. Is there a way to really force the field to use the next available value? Thanks for your help!
  12. Hi PFMaBiSmAd, Let me put it simple in just four words : THANK YOU VERY MUCH ! Sometimes we search the universe while what we are looking for is at our fingertips. I cleared safari's cache, repeated the process and no error occurred. Thank you again. Have a great day. You deserve it.
  13. Hi All, While testing my PHP code on Firefox and Safari, I noticed that one error of type "Parse error: syntax error, unexpected ')'" would display on Safari, but not on FF. Very strange... (Actually there is no extra ')' anyway.) This error appears while clicking repeatedly the back button in the Safari toolbar, once the user has gone through the whole process one way. Doing the same in Firefox does not trigger any error. I thought "Is there really an error on Safari ? If so, it must be possible to record it in a log file". So, to simulate the user's environment, and record all the errors in a .log file, while preventing them to display, I inserted the following lines at the beginning of the script in the file that is mentioned in the error message : error_reporting(E_ALL | E_STRICT); ini_set('error_log', 'test.log'); ini_set('log_errors', 'On'); ini_set('display_errors', 'Off'); Unfortunately, not only I still get the error of type "Parse error: syntax error, unexpected ')'" , but also this error is not recorded into the log file, despite the fact that I did put the error managing code in the PHP file stated in the error message (and that file contains only one PHP script, so no risk to put the error managing code in a wrong script). To test whether that code is functional, I added 1/0; in order to test the division by zero. Now, the error related to the "division by zero" instruction does not display and it is recorded in the .log file, which means that the code is functional. However, the error of type "Parse error: syntax error, unexpected ')'" still displays and does not get recorded into the log file. Any idea of what is going wrong on Safari ? It would be annoying having error messages display in a browser (and possibly reveal some sensitive coding data) while there is actually no error. Thanks for your help.
  14. Thanks for your reply. I was afraid something was wrong in my approach.
  15. Hi All, I have a big problem with session variables getting lost when playing with back/next buttons. This leads to wrong data being displayed, and possibly PHP error messages. From the user's point of view, there is a series of forms to fill in, one form being allowed to display only if ALL previous ones have been correctly filled in. It all works perfectly. But the problem can appear when playing with back/next buttons. Basically, my files are organized as follows. There is a main php file that "drives" the whole structure, where each remaining file contains POST method and SERVER/PHP_SELF action as form settings. This main file contains 2 parts. The first part is where I test/analyse the existence and contents of the POST variables. The second part is where I call the correct form (through an "include" statement) according to the result of the POST test/analysis. For example, if form_1 is correctly filled in, form_2 is called, if not, form_1 is displayed again. In each POST testing, the part that runs if the form is correctly filled in contains two $_SESSION lines. Assuming form_1 POST variable is being analysed, these 2 lines would be something like $_SESSION[form_2_can_be_displayed]=1 and $_SESSION[user_went_through_form_1]=1. $_SESSION[form_2_can_be_displayed] is the variable that is tested for in the second part of the main php file and that will enable to trigger the display of form_2 through an include statement. $_SESSION[user_went_through_form_1] variable is tested for at the beginning of the analysis of POST variable for form_2. In other words, POST variable for form_2 will only be analysed if the user did successfully go through form_1. $_SESSION[user_went_through_form_1] is never unset except at the very beginning of the analysis of POST variable for form_1 in case form_1 had already been successfully submitted by the user. So, as the user moves from form to form, successive $_SESSION[user_went_through_form_XXX] variables get recorded into the global SESSION variable. With such data, I can safely test a POST if ALL previous forms have been passed through. If this condition is not met, a message appears prompting the user to return to the home page. Assuming form_3 POST variable is being parsed, the structure of the test would be something like this (with simplified ELSE details) : If (isset[post_for_form_3]) { If (isset($_SESSION[user_went_through_form_1]) && isset($_SESSION[user_went_through_form_2])) { If (isset($_SESSION([user_went_through_form_3])) { unset $_SESSION([user_went_through_form_3]) } //process the POST variable// If (user-entered data is OK) { $_SESSION([user_went_through_form_3])=1 $_SESSION[form_4_can_be_displayed]=1 } Else { $_SESSION[form_3_can_be_displayed]=1 } } Else { //Instructions to display the "return to home page" message } } As said at the beginning of my post, it all works perfect from the first form to the last one, but afterwards if I randomly play with back/next buttons I may suddenly get the " return to home page" message, meaning that the "isset($_SESSION[user_went_through_form_XXX])" line test has failed. I just do not understand why this happens, because there is no reason why the $_SESSION[user_went_through_form_XXX] should be missing. For example, when falling again on [post_for_form_3], why "isset($_SESSION[user_went_through_form_1])" or "isset($_SESSION[user_went_through_form_2])" should be missing ? These variables were initially set on successful testing of POST variables for form_1 and form_2 and never unset aftewards. Please help ! Thanks !
  16. Hi All, In one of the pages of my site, I extract a series of terms, classified by categories, from a database. Initially, all info was listed in a single column (category name, term list, other category name, other terms list), which left much unused room on the center & right sections of the page. From a CSS code available at http://www.inserthtml.com/2012/01/css3-multi-column-layout-implementation-change-website-design/, I successfully applied a formatting in order to use the whole width of the page. Now the problem is that one category of terms can start at the end of a column and continue at the top of the next one. To force a column break before each category, I associated a <span class="breakhere">category_name</span> tag to the categories and added .breakhere { color: blue; break-before: column; -webkit-column-break-before: column; -moz-column-break-before: column; -ms-column-break-before: column; -o-column-break-before: column; } to the CSS code. This tag is functional since the text does display in blue. However, no column break is applied before the category names. Any idea of what is going wrong ? Thanks !
  17. Hi, Let me rephrase my question. Imagine you developed a long time ago a website for a local audience, and that given its great success you decide to target it to other audiences in other countries. Is there a utility that enables to extract all translatable strings before sending them for translation ? "All" means extracting for example "My Website" from <title>My Website</title> but also from echo 'My Website'; of from echo $a .'My Website'. $b;
  18. Hi All, I want my site to be available in different languages and wonder whether there exists a utility that helps extract from HTML/PHP code all the strings that are likely to be displayed to the user. This will be very helpful when entering the translation process. Any idea or clue ? Thanks.
  19. Well so far I have no specific issue, I am just wondering how to get the best protection against any violation of the website, which is still under construction. There will be a lot of php coding and time spent on it. One of the issues could be redirecting the visitor to another website. I have read in another forum that a hacker can do this by editing a website file. This implies the hacker can access the file. Then other issues can happen : by accessing the php files that make up a website, the hacker can also steal php coding, get database credentials, make any change to the DB, etc, and eventually ruin all the webmaster's efforts, even if the webmaster regularly makes backups of the website and DB. Any suggestions/procedures that a webmaster should follow to implement the highest level of protection are welcome. Thanks. PhD
  20. Sorry, I am not an IT/Internet specialist. Let me try to rephrase again If a hacker just exploits a weakness of the configuration of the server that hosts the website, does this always give them access to the php files of your site and to their contents or do they also need to violate the security procedures set by the webmaster at the website level in order to access the php files? Regards PhD
  21. Thanks for your quick answer. In case of (b), can the hacker open/modify the php files without violating the procedures that the webmaster had set for the website ? Regards, PhD
  22. Let me try to rephrase it. Problem : imagine you own a website that is listed in a Google search results page when the user enters some key words. One day, it appears that when the user clicks the link, the homepage of another website appears instead of the homepage of your website. Questions : (a) can this be due ONLY to a violation of the security procedures implemented by the webmaster for the website (htaccess file, password/login settings, etc) or (b) can it be also achieved by exploiting a weakness of the configuration of the server that hosts your wbsite ? If answer is (b), does a dedicated server (i.e. a server that hosts only your website) offer a better protection ? Thanks. PhD
×
×
  • 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.