Jump to content

hisoka

Members
  • Posts

    569
  • Joined

  • Last visited

Everything posted by hisoka

  1. hisoka

    for loop

    of course these are bitwise operators & this is AND operator << / >> bitwise shift operators | or or operator ^ xor operator
  2. hisoka

    for loop

    this script here var letter = "ab";for(var i=0; i<letter.length; i++){for(var k=0; k<letter.length; k++){var sum = 0;document.write("<br />");document.write(sum += (letter.charCodeAt(i+k%4) & 15 ) << 1);}}</script> gives 2 4 4 0 (97 & 15)<<1= 2 //a (98 & 15)<<1 = 4 //b (98 & 15)<<1 = 4 //b (NaN & 15)<<1 = 0//NaN the second loop , loops like this 0,1 ( a,b)/2,4) 1,2 (b,NaN( 4,0) it is all up to the pointer of the second for loop from where it starts and where to end :rofl: "The problem is that (i + j % 4) can be greater than 2, which is the highest index that a string with three characters can have." that is 97 & 15)<<1= 2 //a (98 & 15)<<1 = 4 //b (98 & 15)<<1 = 4 //b (NaN & 15)<<1 = 0//NaN the second loop , loops like this 0,1 ( a,b)/2,4) 1,2 (b,NaN( 4,0)
  3. hisoka

    for loop

    it is thanks to this "Seriously, why are you using modulus, bitwise and, and bit shifting when you're trying to figure out how loops work?" that I got the inspiration to understand , even for a little degree, how both for loop interact together In this script : var pass = "abc";for(var i=0; i<3; i++){for(j=0 ; j<4 ; j++){var tmp = 0;document.write("<br />");document.write(pass.charCodeAt(i+j%4)+10);}}</script> I noticed the following the first for loop , loops through the string "abc" // it gives 107 108 109 the second loop inside the for loop , loops the result of the first loop a number of times specified in the second statement of the second loop . I also noticed that the number of times the second loop lopps through the result of the first loop is computed by multiplying the number in the second statement of the for loop by the number of the second statement in the for loop 3*4 = 12 . What followed is that I got this as an ouput 107108109NaNNaN109NaNNaNNaN now coming to the result I got , I tried to understand it : first loop of the second loop gives 107 , 108 , 109 second loop of the second loop gives NaN , 108 , 109 third loop of the second loop gives NaN , NaN , 109 fourth loop of the second loop gives NaN , NaN , NaN why it gives NaN because in the first loop it is mentioned that the scan must be i<3 number of times 0<4 = 107 true 1<4 = 108 true 3<4 = 109 true 4=4 false and the loop stops , the second loop when it loops more than three times it surpass the limit of the string and does not find any number so it gives NaN 0<4 = 107 true 1<4 = 108 true 3<4 = 109 true 4 = 4 = false (NaN) I noticed another thing : namely the manner by which the pointer of the second for loop works the for loop loops like this -> begins by zero 0,1,2,3 (107 , 108 ,109 ,NaN) -> turn back and start from one 1,2,3,4 (108,109,NaN , NaN ) -> turn back and start from two 2,3,4,5 (109,NaN , NaN , NaN) now based on that I understand that when I change the number in the second statement of the second for loop I get <script>var pass = "abc";for(var i=0; i<3; i++){for(j=0 ; j<1 ; j++){var tmp = 0;document.write("<br />");document.write(pass.charCodeAt(i+j%4)+10);}}</script> output 107 108 109 I would appreciate it if you correct me in every step and show me my errors
  4. hisoka

    server database

    THANK YOU FROM THE BOTTOM OF MY HEART. now I understand why it shew only a pointer . However I have something that confuses me a lot : I created a table b with two columns named username and password . But when I saw the table using the DESCRIBE b; the table was shown and I got six columns named field, type, null, key ,default ,extra . Normally and logically , after creating a table with two columns named username and password , I must get a table with two columns named username and password and not a table with six columns which have different names . So I am really confused why I got something different from the command I put !!? any explanation? after the explanation , how do I get a table with the columns name I want and let mysql client command echoed it for me as I want it and should be and not as the mysql manual describes here http://dev.mysql.com/doc/refman/5.0/en/creating-tables.html http://dev.mysql.com/doc/refman/5.1/en/create-table.html
  5. hisoka

    for loop

    I wrote this to know what happens when a for loop is inside another <script>var letter = "ab";for(var i=0; i<letter.length; i++){var sum = 0;for(var k=0; k<letter.length; k++){document.write("<br />");document.write(sum += (letter.charCodeAt(i+k%4) & 15 ) << 1);}}</script> it gives 2 6 4 4 I understand the why I got 2 and 6 but I cannot understand why I got 4 then 4 after 2 and 6 so Why ?
  6. hisoka

    operation

    THANK YOU VERY MUCH JUSTSOMEGUY : firefox debugger is helping me a lot and slowly I become familiar with it and I really love it this firefox and its debugger . I hope I will progress with firefox debugger
  7. hisoka

    operation

    "It's because of the <script> tags. That is an HTML tag, not Javascript. Don't put HTML into the Javascript console" very good . I put the script without the <script> and </script> and I got 22 as output However , when I provoked an error like this var p = 10;var p +=(150 & 14) << 1;document.write(p); the browser gave me this error : SyntaxError: missing ; before statement There is no ; that is missing !!!!!! the error was provoked because I put the word var twice . So why is the browser giving an error that does not exist? !!! I do not quite understand this error which has nothing to do with the error that I , intentionally, made namely putting the var twice
  8. hisoka

    server database

    when I go to start - my programs - MySQL - MySQL server (version 5.1) - MySql command line client , the cmd of windows appears in which it is stated : enter password . After entering my password like that enter password : ************* a paragraph appears : Welcome to Mysql monitor . commands end with ....................................type help or 'h' ..... mysql> (ps : I read this http://dev.mysql.com/doc/refman/5.1/en/tutorial.html) so now I am in cmd then when I typed mysql , a pointer appeared then I typed again SELECT VERSION(), CURRENT_DATE; then another pointer appeared . No table appeared like in http://dev.mysql.com/doc/refman/5.1/en/entering-queries.html nothing only pointer like this : mysql> mysql ->SELECT VERSION(), CURRENT_DATE; -> So I said may be the database does not exist like in the error I got : ERROR 1049 (42000): Unknown database 'r' so I tried to create a database like this mysql> CREATE DATABASE admin but the pointer appeared again and nothing else like this : mysql> CREATE DATABASE admin -> Whatsoever , I wrote come only a pointer -> and nothing more mysql> -> -> -> I do not understand why I got only a pointer with nothing else and that I cannot get any table or anything except a pointer -> with an empty value I need help thanks
  9. hisoka

    operation

    it is a good idea to use the browser javascript debugging tools . But it make things more complicated for me : <script>var p = 10;var p +=(150 & 14) << 1;document.write(p);</script> when I clicked on firefox "tools" option then "web developer" then " web console" and put this script <script>var p = 10;var p +=(150 & 14) << 1;document.write(p);</script> Which is 100% correct , not only I got this error :"SyntaxError: expected expression, got '<" which I could not quite digest but it made me angry as my script is correct but it gives an error . So what servers me this option if it will make things complicated for me instead of facilitating things to me ?! The debugger ans style editor and the rest in firefox are complicated to use and load millions of characters I mean they do not facilitate things to me . Are there other options that I do not know? or am I misusing the tools in firefox ? may be you can tell me how toi benefit from these tools and show me what I am ignoring
  10. hisoka

    server database

    edited now I solved many problems and php and mysql are configured to talk together . but I cannot configure mysql to talk with apache Moreover , there is the connect command in cmd windows when I use it like this connect r : unknown mysql server host mysql? I am confused
  11. hisoka

    server database

    thank you for the link "Try Easy PHP. I have it installed on a flash drive so I can use it where ever I need" it is for windows 7/8 it does not support windows xp : EasyPHP DevServer 14.1 VC11 PHP 5.6.x PHP 5.5.x PHP 5.4.x PHP 5.3.x for Windows 7 and 8
  12. hisoka

    operation

    Oh ###### , sometime I become blind and I write javascript in a notepad ( a normal notepad) and execute them without a debugger so that I cannot see when I make an error . After seeing that I made this error that , I normally , should not make . I downloaded , for some minutes , a javascript editor in the hope that it can debug these TRIVIAL errors that sometimes I cannot perceive . the name of the program is : free javascript editor yaldex software version 4.7.2.7 but to my surprise when I click the debug function it does not debug and when I run this script in this javascript editor yaldex <script>var p = 10 // no semi colonp +=(150 & 14) << 1 // no semi colondocument.write(p);</script> it gives me 22 as output although there is no semi colon " ; " at the end of the first and second line in the script . Sometime when I click the run button this yaldex does not executed the script . It becomes like a magical thing I do not know why ??? so why? Why the script was executed correctly although the script is wrong ?? do you know a good and an easy javascript editor with a debugger that I can download in my computer and use it so that it corrects these trivial errors ?? or could you tell me what' s going on with this yaldex software free editor?
  13. hisoka

    server database

    I tried to download XAMPP from this site : https://www.apachefriends.org/download.html I have windows xp 32 bits and the application I tried to download is for windows xp 32 bits . However when I clicked run after saving it , it began to install and , suprisingly at the end , this error appeared : C:xamppphpphp.exe is not a valid win32 application . I tried to download it again but the same error appeared . So I changed the site and I went to another site : http://sourceforge.net/projects/xampp/ and tried to download xampp : I tried two applications : xampp-win32-5.6.3-0-vc.. xampp-win32-1.8.3-5.vc.. but when I try to install them , I got this error : There has been an error : php versions 5.5 and later do not support windows xp so I tried to find xampp with php versions 5.4 or earlier but I could not find one . Some I found but are with virus or adware (not false positive) : they caused problem in my computer . So what could I do ? thanks
  14. hisoka

    operation

    when this script <script>var p =(150 & 14) << 1;document.write(p);</script> is executed , it gives 12 as ouput now when I change the script to this <script>var p = 10; var p +=(150 & 14) << 1;document.write(p);</script> it did not work . Why it did not work? here in this link http://www.w3schools.com/js/js_operators.asp it says : += x += y x = x + y so normally it should give 22 as output var p +=(150 & 14) << 1 is equal to var p = p+((150 & 14) << 1) is equal to 12 + 10 = 22 but as I wrote it did not work . why?
  15. hisoka

    server database

    Have you tested that to see if it works? You can answer your own question. Interesting The thing is that as a newbie I do not know how to do it . Can you please tell me how to do it or test ? I do not have a website or a server Should I install apache and php and mysql together in my computer ??? please tell me what to do and I will do it best regards
  16. hisoka

    server database

    Suppose I have a table in mysql server database and I want to add a row that fits these piece of information username = john password = silverlight is it true if I do it like this : INSERT INTO table (username , password) values ('john' , 'silverlight'); ?? this is the first question the second question is : are these two the same ??? INSERT INTO table (username , password) values ('john' , 'silverlight'); // without single quotes INSERT INTO table ('username' , 'password') values ('john' , 'silverlight'); // with single quotes if not what is the difference ?
  17. hisoka

    for loop

    How many times would this loop execute:for (i = 100; i > 0; i -= 10) 10 times
  18. hisoka

    for loop

    I was very confused at first "My question was WHY it looped endlessly??" the answer to my question , which is given by Foxy Mod is :"Any number that is not zero evaluates to true, so as long as i+1 is not zero, the loop will continue to run" to affirm this : "In JavaScript, a truthy value is a value that translates to true when evaluated in a Boolean context. All values are truthy unless they are defined as falsy" falsy is (zero , undefined , NULL.. ) 1+1 = 2 is always true 3+2 = 5 is always true 10+25 = 35 is always true and so on ... for (var i = 0; i + 5; i++) i+5 is always true therefore the loop run endlessly However for (var i = 0; i <5; i++) 0<5 true 1<5 true 2<5 true 5=5 now i is not <5 so the loop breaks based on that I made some change var a = new Array(1,2,3,4,5,6,7);for(i=0 ; i+7 ; i++){if(a==4 ) // can be 7 or 6 but not more than 7{break;}document.write("<br />");document.write(a);} now I control the loop as for for (var i = 0; i < 5; i++) {alert("Inside the loop, i is " + i);}alert("Outside the loop, i is " + i); the difference is this : in the first case the code inside the for loop runs 4 time and each time the result is echoed meanwhile in the second case the code runs to the end and when it breaks it assigns the end result to the variable then this latter is echoed If I am wrong in all what I wrote , please correct
  19. hisoka

    for loop

    this is an interesting and realistic explanation "Any number that is not zero evaluates to true, so as long as i+1 is not zero, the loop will continue to run" However http://www.w3schools...js_loop_for.asp "If statement 2 returns true, the loop will start over again" for(i=0 ; i<5 ; i++) for(i=0 ; i+5 ; i++) in this case for(i=0 ; i<5 ; i++) i<5 is true because 0<5 is indeed true but the loop did not run endlessly in this case for(i=0 ; i+5 ; i++) i+5 is true because "Any number that is not zero evaluates to true" but the loop run endlessly So why ?
  20. hisoka

    for loop

    Quote Why would it stop? How are you telling it to stop? What is the difference between this : <script>var a = new Array(1,2,3,4,5);for(i=0 ; i<5 ; i++){document.write("<br />");document.write(a);}</script> and this <script>var a = new Array(1,2,3,4,5);for(i=0 ; i+5 ; i++){document.write("<br />");document.write(a);}</script> almost the same . The code to be executed is the same . You can try both of them the first gives (1 2 3 4 5) meanwhile the second loops endlessly until the browser crashes . The only difference is that < is changed to + what provoked that that the loop looped endlessly . My question was WHY it looped endlessly??
  21. hisoka

    for loop

    for(i=0; i+number; i++) { code to be executed; } for(i=0; i+1; i++) { code to be executed; } 1)what does the i+1 means in the for loop ? 2)for what purpose we use i+number in the second statement inside the for loop? 3)why it executes the code endlessly? 4)how to prevent it from executing the code endlessly?
  22. hisoka

    sql

    thank you for the link After reading the link , am I right or wrong when I say that a queue is a collection of organized data that are processed and executed in a first-in-first-out policy ? and if I am right , are the data ,sent by a php application and received by the server database , awaiting for execution organized in a queue and executed in first-in-first-out??? like a group people, in a rank , waiting in the post office . the first who comes is served then it goes then comes the second then and so on .....is it the same with server database ?
  23. hisoka

    sql

    sure https://msdn.microsoft.com/en-us/library/ms186963.aspx There is the word "QUEUE" in the page . Could you tell me what is the exact meaning of the word QUEUE and give me links about the word QUEUE if you know some??
  24. hisoka

    for loop

    yes , the error , as you wrote , was produced because I tried to add an array to a number
×
×
  • Create New...