calling PHP script- getting the script as an output
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
I wrote a simple PHP script to connect to a SQL database. I ran chmod +x script.php
. The problem is that when I call the script (./script.php
) the output is the script itself (the whole script written as an output). Any ideas what I'm missing?
#!/usr/bin/php
<?
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
echo "Connected successfully";
?>
php
add a comment |Â
up vote
1
down vote
favorite
I wrote a simple PHP script to connect to a SQL database. I ran chmod +x script.php
. The problem is that when I call the script (./script.php
) the output is the script itself (the whole script written as an output). Any ideas what I'm missing?
#!/usr/bin/php
<?
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
echo "Connected successfully";
?>
php
1
Short tags are probably disabled. Replace<?
with<?php
â vidarlo
Mar 21 at 20:05
That was the problem. Thanks vidarlo
â ItInNeed
Mar 21 at 20:16
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I wrote a simple PHP script to connect to a SQL database. I ran chmod +x script.php
. The problem is that when I call the script (./script.php
) the output is the script itself (the whole script written as an output). Any ideas what I'm missing?
#!/usr/bin/php
<?
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
echo "Connected successfully";
?>
php
I wrote a simple PHP script to connect to a SQL database. I ran chmod +x script.php
. The problem is that when I call the script (./script.php
) the output is the script itself (the whole script written as an output). Any ideas what I'm missing?
#!/usr/bin/php
<?
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
echo "Connected successfully";
?>
php
php
edited Apr 5 at 23:57
![](https://i.stack.imgur.com/Cfz2Q.jpg?s=32&g=1)
![](https://i.stack.imgur.com/Cfz2Q.jpg?s=32&g=1)
Elder Geek
25.3k949120
25.3k949120
asked Mar 21 at 19:48
ItInNeed
61
61
1
Short tags are probably disabled. Replace<?
with<?php
â vidarlo
Mar 21 at 20:05
That was the problem. Thanks vidarlo
â ItInNeed
Mar 21 at 20:16
add a comment |Â
1
Short tags are probably disabled. Replace<?
with<?php
â vidarlo
Mar 21 at 20:05
That was the problem. Thanks vidarlo
â ItInNeed
Mar 21 at 20:16
1
1
Short tags are probably disabled. Replace
<?
with <?php
â vidarlo
Mar 21 at 20:05
Short tags are probably disabled. Replace
<?
with <?php
â vidarlo
Mar 21 at 20:05
That was the problem. Thanks vidarlo
â ItInNeed
Mar 21 at 20:16
That was the problem. Thanks vidarlo
â ItInNeed
Mar 21 at 20:16
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
As @vidarlo suggests, the short tags directive in the PHP configuration file is disabled.
If you'd like to use the short tags syntax, you'll have to enable it.
Change your php.ini file accordingly:
short_open_tag=On
And restart apache. Assuming you're using some kind of Debian-based system and apache2, execute the following command (or similar, depending on your system):
sudo service apache2 restart
Note: If you don't know where your php.ini configuration file is, just run the following in the terminal:
php --ini
1
It appears he is not using apache2 (or any web server). Anyway, I'd say don't enable short tags; change tags to the long form in the script. Short tags are discouraged, and makes scripts less portable. There's no reason to use them.
â vidarlo
Mar 22 at 6:24
Well, we use short tags in all of our projects, but only in the views. In my opinion, it improves the readability.
â Brood
Mar 23 at 20:59
I don't see how a tag that is not repeated trough code improves readability. I typically see it on the first line of the file... Anyway, that is not really the point. Long tags eases portability, as it is supported everywhere, and it is enabled by default. In addition I'd not feel sure that short tags will be around for that long either...
â vidarlo
Mar 24 at 9:53
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
As @vidarlo suggests, the short tags directive in the PHP configuration file is disabled.
If you'd like to use the short tags syntax, you'll have to enable it.
Change your php.ini file accordingly:
short_open_tag=On
And restart apache. Assuming you're using some kind of Debian-based system and apache2, execute the following command (or similar, depending on your system):
sudo service apache2 restart
Note: If you don't know where your php.ini configuration file is, just run the following in the terminal:
php --ini
1
It appears he is not using apache2 (or any web server). Anyway, I'd say don't enable short tags; change tags to the long form in the script. Short tags are discouraged, and makes scripts less portable. There's no reason to use them.
â vidarlo
Mar 22 at 6:24
Well, we use short tags in all of our projects, but only in the views. In my opinion, it improves the readability.
â Brood
Mar 23 at 20:59
I don't see how a tag that is not repeated trough code improves readability. I typically see it on the first line of the file... Anyway, that is not really the point. Long tags eases portability, as it is supported everywhere, and it is enabled by default. In addition I'd not feel sure that short tags will be around for that long either...
â vidarlo
Mar 24 at 9:53
add a comment |Â
up vote
1
down vote
As @vidarlo suggests, the short tags directive in the PHP configuration file is disabled.
If you'd like to use the short tags syntax, you'll have to enable it.
Change your php.ini file accordingly:
short_open_tag=On
And restart apache. Assuming you're using some kind of Debian-based system and apache2, execute the following command (or similar, depending on your system):
sudo service apache2 restart
Note: If you don't know where your php.ini configuration file is, just run the following in the terminal:
php --ini
1
It appears he is not using apache2 (or any web server). Anyway, I'd say don't enable short tags; change tags to the long form in the script. Short tags are discouraged, and makes scripts less portable. There's no reason to use them.
â vidarlo
Mar 22 at 6:24
Well, we use short tags in all of our projects, but only in the views. In my opinion, it improves the readability.
â Brood
Mar 23 at 20:59
I don't see how a tag that is not repeated trough code improves readability. I typically see it on the first line of the file... Anyway, that is not really the point. Long tags eases portability, as it is supported everywhere, and it is enabled by default. In addition I'd not feel sure that short tags will be around for that long either...
â vidarlo
Mar 24 at 9:53
add a comment |Â
up vote
1
down vote
up vote
1
down vote
As @vidarlo suggests, the short tags directive in the PHP configuration file is disabled.
If you'd like to use the short tags syntax, you'll have to enable it.
Change your php.ini file accordingly:
short_open_tag=On
And restart apache. Assuming you're using some kind of Debian-based system and apache2, execute the following command (or similar, depending on your system):
sudo service apache2 restart
Note: If you don't know where your php.ini configuration file is, just run the following in the terminal:
php --ini
As @vidarlo suggests, the short tags directive in the PHP configuration file is disabled.
If you'd like to use the short tags syntax, you'll have to enable it.
Change your php.ini file accordingly:
short_open_tag=On
And restart apache. Assuming you're using some kind of Debian-based system and apache2, execute the following command (or similar, depending on your system):
sudo service apache2 restart
Note: If you don't know where your php.ini configuration file is, just run the following in the terminal:
php --ini
answered Mar 21 at 22:01
![](https://i.stack.imgur.com/EvNIG.png?s=32&g=1)
![](https://i.stack.imgur.com/EvNIG.png?s=32&g=1)
Brood
407410
407410
1
It appears he is not using apache2 (or any web server). Anyway, I'd say don't enable short tags; change tags to the long form in the script. Short tags are discouraged, and makes scripts less portable. There's no reason to use them.
â vidarlo
Mar 22 at 6:24
Well, we use short tags in all of our projects, but only in the views. In my opinion, it improves the readability.
â Brood
Mar 23 at 20:59
I don't see how a tag that is not repeated trough code improves readability. I typically see it on the first line of the file... Anyway, that is not really the point. Long tags eases portability, as it is supported everywhere, and it is enabled by default. In addition I'd not feel sure that short tags will be around for that long either...
â vidarlo
Mar 24 at 9:53
add a comment |Â
1
It appears he is not using apache2 (or any web server). Anyway, I'd say don't enable short tags; change tags to the long form in the script. Short tags are discouraged, and makes scripts less portable. There's no reason to use them.
â vidarlo
Mar 22 at 6:24
Well, we use short tags in all of our projects, but only in the views. In my opinion, it improves the readability.
â Brood
Mar 23 at 20:59
I don't see how a tag that is not repeated trough code improves readability. I typically see it on the first line of the file... Anyway, that is not really the point. Long tags eases portability, as it is supported everywhere, and it is enabled by default. In addition I'd not feel sure that short tags will be around for that long either...
â vidarlo
Mar 24 at 9:53
1
1
It appears he is not using apache2 (or any web server). Anyway, I'd say don't enable short tags; change tags to the long form in the script. Short tags are discouraged, and makes scripts less portable. There's no reason to use them.
â vidarlo
Mar 22 at 6:24
It appears he is not using apache2 (or any web server). Anyway, I'd say don't enable short tags; change tags to the long form in the script. Short tags are discouraged, and makes scripts less portable. There's no reason to use them.
â vidarlo
Mar 22 at 6:24
Well, we use short tags in all of our projects, but only in the views. In my opinion, it improves the readability.
â Brood
Mar 23 at 20:59
Well, we use short tags in all of our projects, but only in the views. In my opinion, it improves the readability.
â Brood
Mar 23 at 20:59
I don't see how a tag that is not repeated trough code improves readability. I typically see it on the first line of the file... Anyway, that is not really the point. Long tags eases portability, as it is supported everywhere, and it is enabled by default. In addition I'd not feel sure that short tags will be around for that long either...
â vidarlo
Mar 24 at 9:53
I don't see how a tag that is not repeated trough code improves readability. I typically see it on the first line of the file... Anyway, that is not really the point. Long tags eases portability, as it is supported everywhere, and it is enabled by default. In addition I'd not feel sure that short tags will be around for that long either...
â vidarlo
Mar 24 at 9:53
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1018051%2fcalling-php-script-getting-the-script-as-an-output%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Short tags are probably disabled. Replace
<?
with<?php
â vidarlo
Mar 21 at 20:05
That was the problem. Thanks vidarlo
â ItInNeed
Mar 21 at 20:16