General Jsrcript Questions

Discussion in 'JavaScript' started by Jeremy Benson, Nov 8, 2013.

  1. #1
    Hello,

    I've learned some php, and finally started getting handy with it, but learned there was certain things that shouldn't be done with it, because every request needs to be sent to a page. After skimming some javascript books I came to the conclusion I can't figure out a legitimate use for Javascript.

    My mental hurdles include not being able to communicate with a database, and the inability to use Jscript with PHP.

    Since the two languages can't communicate and java can't get into the database I'm not sure where to start with developing a web application in javascript language.

    I have a basic idea that I'd like to create something that works a bit like twitter, and maybe learn to create programs that run like other social networks...

    the problem is I can't seem to figure out how to do it without PHP, which is what I would want to do for efficiency, and what not..
    I really can't get past storing friend information, and comments, and stuff like that in a database... Would it actually be better to use xml for stuff like this?

    any help would be great,
    thanks.
     
    Jeremy Benson, Nov 8, 2013 IP
  2. MrLeN

    MrLeN Well-Known Member

    Messages:
    406
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Javascript is for browser/client side stuff.

    PHP is for back end stuff.

    I write a lot of php to flat files - then include the file and get the variables out of the saved file.

    How to write a file

    I write a lot of simple stuff with absolutely no need for a MySQL database.

    I use cookies and sessions to store stuff. I get away with writing some realy cool websites using nothing buy php and flat files (and some sessions and cookies) -- and aweber.

    As amatter of fact, I am currently writing a website in php wich allows people to subscribe to 5 (stored) twitter people (*referrers), and then they get their twtter name added to the site with some referrers stored as variables, and so on and so forth - so hundreds of thousands of people can build a follower downline. I am passing all users through an aweber form, so I am getting their email address at aweber while I'm at it.

    I'm gonna make a kiling. All using php and flat files :)
     
    MrLeN, Nov 17, 2013 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    So, you're building a Twitter-subscriber pyramid scheme. With flat files. And people wonder why the web is going to the dogs.

    To OP: you can perfectly fine use javascript to communicate with a database - but you have to go via some sort of server side scripting - like PHP.

    User fills out form (say login) -> javascript gathers the information from the form and sends it to a PHP-file -> the PHP file processes the received data, and uses the data to check for a user/password combo and logs the user in if found. (Very simplified, but you should get the point).

    Besides, do NOT use "java" to refer to javascript. JAVA is a programming language, and have nothing to do with javascript at all. Refer to javascript as "js" if you need to do shorthand.
     
    PoPSiCLe, Nov 19, 2013 IP
  4. Jeremy Benson

    Jeremy Benson Well-Known Member

    Messages:
    364
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    123
    #4
    Hey, thanks PoPSiCLe. After posting this I dug into some books and learned some JavaScript and Ajax, so I have a pretty good handle on what I need... Just have to learn to use it better.

    Thanks again.
     
    Jeremy Benson, Nov 19, 2013 IP
  5. Thunderbreeze

    Thunderbreeze Member

    Messages:
    12
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    28
    #5
    Thank you for the post clarifying javascript vs. PHP. It helped me to see the overall picture of what I need to learn.
     
    Thunderbreeze, Mar 8, 2014 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #6
    Java is to JavaScript as Ham is to Hamburger... that's the best way I know to explain it to people.
     
    deathshadow, Mar 8, 2014 IP
  7. Thunderbreeze

    Thunderbreeze Member

    Messages:
    12
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    28
    #7
    LOL, I love this analogy. Mind if I borrow it?
     
    Thunderbreeze, Mar 9, 2014 IP