Author Topic: Best programming language for server-side web programming  (Read 6683 times)

0 Members and 1 Guest are viewing this topic.

Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1345
  • Post Rating Ratio: +11/-2
    • @0xbmuessig
    • @muessigb
  • Gender: Male
Should I turn my existing HTML into a PHP or should I create a separate PHP?
Both would work. But I guess keep them seperate.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc, Hewlett-Packard 100LX, Hewlett-Packard 95LX
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Hewlett-Packard 95LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5

Offline Ephraim Becker

  • Full User
  • Join Date: Mar 2015
  • Location: Far Rockaway, NY
  • Posts: 118
  • Post Rating Ratio: +0/-4
    • @UCIHxAXYLxYlNaQiv0do0bUg
    • EphraimB
    • 112/11290
  • Gender: Male
Is it best to put the PHP file in another folder or in the same directory as the HTML?
  • Calculators owned: TI 84 Plus, TI 84 Plus C Silver Edition, TI 84 Plus CE, Casio FX-9750 GII
I have Aspergers Syndrome

Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1345
  • Post Rating Ratio: +11/-2
    • @0xbmuessig
    • @muessigb
  • Gender: Male
Is it best to put the PHP file in another folder or in the same directory as the HTML?
Same directory is better though it doesn't really matter.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc, Hewlett-Packard 100LX, Hewlett-Packard 95LX
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Hewlett-Packard 95LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5

Offline Ephraim Becker

  • Full User
  • Join Date: Mar 2015
  • Location: Far Rockaway, NY
  • Posts: 118
  • Post Rating Ratio: +0/-4
    • @UCIHxAXYLxYlNaQiv0do0bUg
    • EphraimB
    • 112/11290
  • Gender: Male
I have my CSS, JavaScript, and images each in a separate folder and I have my HTML as the root of my webpage project. Should my PHP go in it's separate folder also?
  • Calculators owned: TI 84 Plus, TI 84 Plus C Silver Edition, TI 84 Plus CE, Casio FX-9750 GII
I have Aspergers Syndrome

Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1345
  • Post Rating Ratio: +11/-2
    • @0xbmuessig
    • @muessigb
  • Gender: Male
I have my CSS, JavaScript, and images each in a separate folder and I have my HTML as the root of my webpage project. Should my PHP go in it's separate folder also?
You decide. Either same folder or folder below it.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc, Hewlett-Packard 100LX, Hewlett-Packard 95LX
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Hewlett-Packard 95LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5

Offline Ephraim Becker

  • Full User
  • Join Date: Mar 2015
  • Location: Far Rockaway, NY
  • Posts: 118
  • Post Rating Ratio: +0/-4
    • @UCIHxAXYLxYlNaQiv0do0bUg
    • EphraimB
    • 112/11290
  • Gender: Male
How do I link the PHP to my other website files?

Update: I don't think I can do that. I have to turn index.html into index.php

Update 2: I think all I need to do is link the PHP to the JavaScript
« Last Edit: November 15, 2015, 02:27:03 am by Ephraim Becker »
  • Calculators owned: TI 84 Plus, TI 84 Plus C Silver Edition, TI 84 Plus CE, Casio FX-9750 GII
I have Aspergers Syndrome

Offline alexgt

  • Just your friendly neighborhood Ninja Stach Fancy Iron Man
  • Super User
  • Join Date: Dec 2014
  • Location: Behind you
  • Posts: 2615
  • Post Rating Ratio: +6/-1
  • Something should go here...
    • /u/alexgt9123
  • Gender: Male
Just integrate PHP into HTML or visa versa
  • Calculators owned: Ti-84+, Ti-Nspire, Hp Prime, Broken HP Prime, HP 48SX

Offline Ephraim Becker

  • Full User
  • Join Date: Mar 2015
  • Location: Far Rockaway, NY
  • Posts: 118
  • Post Rating Ratio: +0/-4
    • @UCIHxAXYLxYlNaQiv0do0bUg
    • EphraimB
    • 112/11290
  • Gender: Male
The JavaScript file is interpreting the PHP file as undefined:

PHP code:
Code: [Select]
<?php
$url 
"http://www.winbeta.com/feed";
$str file_get_contents ($url);

echo 
"Testing";
?>

JavaScript code:
Code: [Select]
function technology()
{
    personTwoSays.value = "";
    submitButtonThree.style.display = "none";

    var submitButtonFour = document.createElement("button");

    submitButtonFour.innerHTML = "Submit";
    personTwoTalk.appendChild(submitButtonFour);
    personTwoSays.setAttribute("placeholder", "Type reply...");

//Get the latest technology news from the internet
function fetchLatestNews()
{
    var request = new XMLHttpRequest();

    request.open("GET", "../php/news.php");
    request.send();
};

    personOneTalk.innerHTML = "Sure! Have you heard of " + fetchLatestNews();
};
« Last Edit: November 15, 2015, 03:07:17 am by Ephraim Becker »
  • Calculators owned: TI 84 Plus, TI 84 Plus C Silver Edition, TI 84 Plus CE, Casio FX-9750 GII
I have Aspergers Syndrome

Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1345
  • Post Rating Ratio: +11/-2
    • @0xbmuessig
    • @muessigb
  • Gender: Male
The JavaScript file is interpreting the PHP file as undefined:

PHP code:
<?php
$url = "http://www.winbeta.com/feed";
$str = file_get_contents ($url);

echo "Testing";
?>

JavaScript code:
function technology()
{
personTwoSays.value = "";
submitButtonThree.style.display = "none";

var submitButtonFour = document.createElement("button");

submitButtonFour.innerHTML = "Submit";
personTwoTalk.appendChild(submitButtonFour);
personTwoSays.setAttribute("placeholder", "Type reply...");

//Get the latest technology news from the internet
function fetchLatestNews()
{
var request = new XMLHttpRequest();

request.open("GET", "../php/news.php");
request.send();
};

personOneTalk.innerHTML = "Sure! Have you heard of " + fetchLatestNews();
};
Go for json after all:

Php: print(json_encode(array("ab"=>123)));

JavaScript: JSON.decode(string)

Edit how are your files placed in folders? Which file is where?
« Last Edit: November 15, 2015, 03:02:09 am by DarkestEx »
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc, Hewlett-Packard 100LX, Hewlett-Packard 95LX
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Hewlett-Packard 95LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5

Offline Ephraim Becker

  • Full User
  • Join Date: Mar 2015
  • Location: Far Rockaway, NY
  • Posts: 118
  • Post Rating Ratio: +0/-4
    • @UCIHxAXYLxYlNaQiv0do0bUg
    • EphraimB
    • 112/11290
  • Gender: Male
index.html is at the root of the project folder. The JavaScript file is in the js folder and the PHP file is in the php folder.
  • Calculators owned: TI 84 Plus, TI 84 Plus C Silver Edition, TI 84 Plus CE, Casio FX-9750 GII
I have Aspergers Syndrome

Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1345
  • Post Rating Ratio: +11/-2
    • @0xbmuessig
    • @muessigb
  • Gender: Male
index.html is at the root of the project folder. The JavaScript file is in the js folder and the PHP file is in the php folder.

Try to do php/ instead of ../php/
I don't know if it will fix it.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc, Hewlett-Packard 100LX, Hewlett-Packard 95LX
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Hewlett-Packard 95LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5

Offline Ephraim Becker

  • Full User
  • Join Date: Mar 2015
  • Location: Far Rockaway, NY
  • Posts: 118
  • Post Rating Ratio: +0/-4
    • @UCIHxAXYLxYlNaQiv0do0bUg
    • EphraimB
    • 112/11290
  • Gender: Male
No. It doesn't fix the problem. It still says undefined.
  • Calculators owned: TI 84 Plus, TI 84 Plus C Silver Edition, TI 84 Plus CE, Casio FX-9750 GII
I have Aspergers Syndrome

Offline jacobly

  • New User
  • CodeWalrus Supporter
  • *
  • Safe-haven access
  • Join Date: Sep 2015
  • Location:
  • Posts: 8
  • Post Rating Ratio: +0/-0
It says undefined because fetchLatestNews() doesn't return anything and functions that don't return anything return undefined.  You probably want to add an event listener for the load event to request so you can display the result of the request.

Offline Ephraim Becker

  • Full User
  • Join Date: Mar 2015
  • Location: Far Rockaway, NY
  • Posts: 118
  • Post Rating Ratio: +0/-4
    • @UCIHxAXYLxYlNaQiv0do0bUg
    • EphraimB
    • 112/11290
  • Gender: Male
How do I make my function return the output of the PHP file?
« Last Edit: November 15, 2015, 03:57:54 am by Ephraim Becker »
  • Calculators owned: TI 84 Plus, TI 84 Plus C Silver Edition, TI 84 Plus CE, Casio FX-9750 GII
I have Aspergers Syndrome

Offline jacobly

  • New User
  • CodeWalrus Supporter
  • *
  • Safe-haven access
  • Join Date: Sep 2015
  • Location:
  • Posts: 8
  • Post Rating Ratio: +0/-0
Something like:
Code: (JavaScript) [Select]
function technology()
{
    personTwoSays.value = "";
    submitButtonThree.style.display = "none";

    var submitButtonFour = document.createElement("button");

    submitButtonFour.innerHTML = "Submit";
    personTwoTalk.appendChild(submitButtonFour);
    personTwoSays.setAttribute("placeholder", "Type reply...");

//Get the latest technology news from the internet
function fetchLatestNews()
{
    var request = new XMLHttpRequest();
    request.addEventListener("load", handleResponse);
    request.open("GET", "php/news.php");
    request.send();
}

function handleResponse() {
    personOneTalk.innerHTML = "Sure! Have you heard of " + this.responseText;
}

    fetchLatestNews();
};

Edit: In response to your edit, you can't really return the result of an asynchronous request in javascript.
« Last Edit: November 15, 2015, 04:07:40 am by jacobly »

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games