PHP Source Query works on localhost but not on server





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have used this https://github.com/xPaw/PHP-Source-Query API for querying ARK server information on a website. Everything works perfectly on localhost, but not when uploaded on the web server. PHP works otherwise on the server, but not just this one feature. The Apache error log on server says this when the page is loaded:



"PHP Parse error:  syntax error, unexpected ''xPaw/SourceQuery
/SourceQuery'' (T_CONSTANT_ENCAPSED_STRING), expecting identifier
(T_STRING) or function (T_FUNCTION) or const (T_CONST) or \\
(T_NS_SEPARATOR) in /var/www/jamon/serverinfo.php on line 4, referer:
https://jamonparadigm.com/servers"


The web server is running PHP 7. The serverinfo.php looks like this:



<?php
require __DIR__ . '/SourceQuery/bootstrap.php';

use xPawSourceQuerySourceQuery;

// For the sake of this example
Header( 'Content-Type: text/plain' );
Header( 'X-Content-Type-Options: nosniff' );

// The Island
define( 'SQ_SERVER_ADDR', '159.69.56.156' );
define( 'SQ_SERVER_PORT', 27000 );
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery::SOURCE );

$Query = new SourceQuery( );

try
{
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );

$islandInfo = $Query->GetInfo( );
$islandPlayers = $islandInfo['Players'] . "/" . $islandInfo['MaxPlayers'];
$islandVersion = trim(substr($islandInfo['HostName'], strpos($islandInfo['HostName'], '(')), "()");
$islandStatus = '<span class="text-success">online</span>';
$islandInfo2 = $Query->GetRules();
$islandDay = $islandInfo2['DayTime_s'];
}
catch( Exception $e )
{
$islandPlayers = "0/0";
$islandVersion = "";
$islandStatus = '<span class="text-danger">offline</span>';
$islandDay = "";
}
finally
{
$Query->Disconnect( );
}
?>


What could be done to fix the issue?










share|improve this question























  • It may be a case of checking the SourceQuery/bootstrap.php to see if there is anything at the end of that which is causing the problem.

    – Nigel Ren
    Nov 23 '18 at 19:34











  • hmmm... Error message says that you have another line in your file on server than the one you've posted as a question. it says you have: use 'xPawSourceQuerySourceQuery'; with quoted namespace - which is wrong. Try to upload new file where make this line up or down to be sure that the version you hav on dev is the same as the one on your remote.

    – Alex
    Nov 23 '18 at 20:08











  • Ah, now I figured it out! The bootstrap.php had everything included with "require_once", and since my serverinfo.php page has multiple queries, all those had to be changed to "require". A stupid mistake, but thanks for helping me notice it.

    – Zerahar
    Nov 23 '18 at 20:18











  • Please extract a Minimal, Complete, and Verifiable example from your code. That said, as a new user, please take the tour and read How to Ask.

    – Ulrich Eckhardt
    Nov 23 '18 at 22:34


















0















I have used this https://github.com/xPaw/PHP-Source-Query API for querying ARK server information on a website. Everything works perfectly on localhost, but not when uploaded on the web server. PHP works otherwise on the server, but not just this one feature. The Apache error log on server says this when the page is loaded:



"PHP Parse error:  syntax error, unexpected ''xPaw/SourceQuery
/SourceQuery'' (T_CONSTANT_ENCAPSED_STRING), expecting identifier
(T_STRING) or function (T_FUNCTION) or const (T_CONST) or \\
(T_NS_SEPARATOR) in /var/www/jamon/serverinfo.php on line 4, referer:
https://jamonparadigm.com/servers"


The web server is running PHP 7. The serverinfo.php looks like this:



<?php
require __DIR__ . '/SourceQuery/bootstrap.php';

use xPawSourceQuerySourceQuery;

// For the sake of this example
Header( 'Content-Type: text/plain' );
Header( 'X-Content-Type-Options: nosniff' );

// The Island
define( 'SQ_SERVER_ADDR', '159.69.56.156' );
define( 'SQ_SERVER_PORT', 27000 );
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery::SOURCE );

$Query = new SourceQuery( );

try
{
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );

$islandInfo = $Query->GetInfo( );
$islandPlayers = $islandInfo['Players'] . "/" . $islandInfo['MaxPlayers'];
$islandVersion = trim(substr($islandInfo['HostName'], strpos($islandInfo['HostName'], '(')), "()");
$islandStatus = '<span class="text-success">online</span>';
$islandInfo2 = $Query->GetRules();
$islandDay = $islandInfo2['DayTime_s'];
}
catch( Exception $e )
{
$islandPlayers = "0/0";
$islandVersion = "";
$islandStatus = '<span class="text-danger">offline</span>';
$islandDay = "";
}
finally
{
$Query->Disconnect( );
}
?>


What could be done to fix the issue?










share|improve this question























  • It may be a case of checking the SourceQuery/bootstrap.php to see if there is anything at the end of that which is causing the problem.

    – Nigel Ren
    Nov 23 '18 at 19:34











  • hmmm... Error message says that you have another line in your file on server than the one you've posted as a question. it says you have: use 'xPawSourceQuerySourceQuery'; with quoted namespace - which is wrong. Try to upload new file where make this line up or down to be sure that the version you hav on dev is the same as the one on your remote.

    – Alex
    Nov 23 '18 at 20:08











  • Ah, now I figured it out! The bootstrap.php had everything included with "require_once", and since my serverinfo.php page has multiple queries, all those had to be changed to "require". A stupid mistake, but thanks for helping me notice it.

    – Zerahar
    Nov 23 '18 at 20:18











  • Please extract a Minimal, Complete, and Verifiable example from your code. That said, as a new user, please take the tour and read How to Ask.

    – Ulrich Eckhardt
    Nov 23 '18 at 22:34














0












0








0








I have used this https://github.com/xPaw/PHP-Source-Query API for querying ARK server information on a website. Everything works perfectly on localhost, but not when uploaded on the web server. PHP works otherwise on the server, but not just this one feature. The Apache error log on server says this when the page is loaded:



"PHP Parse error:  syntax error, unexpected ''xPaw/SourceQuery
/SourceQuery'' (T_CONSTANT_ENCAPSED_STRING), expecting identifier
(T_STRING) or function (T_FUNCTION) or const (T_CONST) or \\
(T_NS_SEPARATOR) in /var/www/jamon/serverinfo.php on line 4, referer:
https://jamonparadigm.com/servers"


The web server is running PHP 7. The serverinfo.php looks like this:



<?php
require __DIR__ . '/SourceQuery/bootstrap.php';

use xPawSourceQuerySourceQuery;

// For the sake of this example
Header( 'Content-Type: text/plain' );
Header( 'X-Content-Type-Options: nosniff' );

// The Island
define( 'SQ_SERVER_ADDR', '159.69.56.156' );
define( 'SQ_SERVER_PORT', 27000 );
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery::SOURCE );

$Query = new SourceQuery( );

try
{
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );

$islandInfo = $Query->GetInfo( );
$islandPlayers = $islandInfo['Players'] . "/" . $islandInfo['MaxPlayers'];
$islandVersion = trim(substr($islandInfo['HostName'], strpos($islandInfo['HostName'], '(')), "()");
$islandStatus = '<span class="text-success">online</span>';
$islandInfo2 = $Query->GetRules();
$islandDay = $islandInfo2['DayTime_s'];
}
catch( Exception $e )
{
$islandPlayers = "0/0";
$islandVersion = "";
$islandStatus = '<span class="text-danger">offline</span>';
$islandDay = "";
}
finally
{
$Query->Disconnect( );
}
?>


What could be done to fix the issue?










share|improve this question














I have used this https://github.com/xPaw/PHP-Source-Query API for querying ARK server information on a website. Everything works perfectly on localhost, but not when uploaded on the web server. PHP works otherwise on the server, but not just this one feature. The Apache error log on server says this when the page is loaded:



"PHP Parse error:  syntax error, unexpected ''xPaw/SourceQuery
/SourceQuery'' (T_CONSTANT_ENCAPSED_STRING), expecting identifier
(T_STRING) or function (T_FUNCTION) or const (T_CONST) or \\
(T_NS_SEPARATOR) in /var/www/jamon/serverinfo.php on line 4, referer:
https://jamonparadigm.com/servers"


The web server is running PHP 7. The serverinfo.php looks like this:



<?php
require __DIR__ . '/SourceQuery/bootstrap.php';

use xPawSourceQuerySourceQuery;

// For the sake of this example
Header( 'Content-Type: text/plain' );
Header( 'X-Content-Type-Options: nosniff' );

// The Island
define( 'SQ_SERVER_ADDR', '159.69.56.156' );
define( 'SQ_SERVER_PORT', 27000 );
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery::SOURCE );

$Query = new SourceQuery( );

try
{
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );

$islandInfo = $Query->GetInfo( );
$islandPlayers = $islandInfo['Players'] . "/" . $islandInfo['MaxPlayers'];
$islandVersion = trim(substr($islandInfo['HostName'], strpos($islandInfo['HostName'], '(')), "()");
$islandStatus = '<span class="text-success">online</span>';
$islandInfo2 = $Query->GetRules();
$islandDay = $islandInfo2['DayTime_s'];
}
catch( Exception $e )
{
$islandPlayers = "0/0";
$islandVersion = "";
$islandStatus = '<span class="text-danger">offline</span>';
$islandDay = "";
}
finally
{
$Query->Disconnect( );
}
?>


What could be done to fix the issue?







php steam






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 19:22









ZeraharZerahar

11




11













  • It may be a case of checking the SourceQuery/bootstrap.php to see if there is anything at the end of that which is causing the problem.

    – Nigel Ren
    Nov 23 '18 at 19:34











  • hmmm... Error message says that you have another line in your file on server than the one you've posted as a question. it says you have: use 'xPawSourceQuerySourceQuery'; with quoted namespace - which is wrong. Try to upload new file where make this line up or down to be sure that the version you hav on dev is the same as the one on your remote.

    – Alex
    Nov 23 '18 at 20:08











  • Ah, now I figured it out! The bootstrap.php had everything included with "require_once", and since my serverinfo.php page has multiple queries, all those had to be changed to "require". A stupid mistake, but thanks for helping me notice it.

    – Zerahar
    Nov 23 '18 at 20:18











  • Please extract a Minimal, Complete, and Verifiable example from your code. That said, as a new user, please take the tour and read How to Ask.

    – Ulrich Eckhardt
    Nov 23 '18 at 22:34



















  • It may be a case of checking the SourceQuery/bootstrap.php to see if there is anything at the end of that which is causing the problem.

    – Nigel Ren
    Nov 23 '18 at 19:34











  • hmmm... Error message says that you have another line in your file on server than the one you've posted as a question. it says you have: use 'xPawSourceQuerySourceQuery'; with quoted namespace - which is wrong. Try to upload new file where make this line up or down to be sure that the version you hav on dev is the same as the one on your remote.

    – Alex
    Nov 23 '18 at 20:08











  • Ah, now I figured it out! The bootstrap.php had everything included with "require_once", and since my serverinfo.php page has multiple queries, all those had to be changed to "require". A stupid mistake, but thanks for helping me notice it.

    – Zerahar
    Nov 23 '18 at 20:18











  • Please extract a Minimal, Complete, and Verifiable example from your code. That said, as a new user, please take the tour and read How to Ask.

    – Ulrich Eckhardt
    Nov 23 '18 at 22:34

















It may be a case of checking the SourceQuery/bootstrap.php to see if there is anything at the end of that which is causing the problem.

– Nigel Ren
Nov 23 '18 at 19:34





It may be a case of checking the SourceQuery/bootstrap.php to see if there is anything at the end of that which is causing the problem.

– Nigel Ren
Nov 23 '18 at 19:34













hmmm... Error message says that you have another line in your file on server than the one you've posted as a question. it says you have: use 'xPawSourceQuerySourceQuery'; with quoted namespace - which is wrong. Try to upload new file where make this line up or down to be sure that the version you hav on dev is the same as the one on your remote.

– Alex
Nov 23 '18 at 20:08





hmmm... Error message says that you have another line in your file on server than the one you've posted as a question. it says you have: use 'xPawSourceQuerySourceQuery'; with quoted namespace - which is wrong. Try to upload new file where make this line up or down to be sure that the version you hav on dev is the same as the one on your remote.

– Alex
Nov 23 '18 at 20:08













Ah, now I figured it out! The bootstrap.php had everything included with "require_once", and since my serverinfo.php page has multiple queries, all those had to be changed to "require". A stupid mistake, but thanks for helping me notice it.

– Zerahar
Nov 23 '18 at 20:18





Ah, now I figured it out! The bootstrap.php had everything included with "require_once", and since my serverinfo.php page has multiple queries, all those had to be changed to "require". A stupid mistake, but thanks for helping me notice it.

– Zerahar
Nov 23 '18 at 20:18













Please extract a Minimal, Complete, and Verifiable example from your code. That said, as a new user, please take the tour and read How to Ask.

– Ulrich Eckhardt
Nov 23 '18 at 22:34





Please extract a Minimal, Complete, and Verifiable example from your code. That said, as a new user, please take the tour and read How to Ask.

– Ulrich Eckhardt
Nov 23 '18 at 22:34












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451999%2fphp-source-query-works-on-localhost-but-not-on-server%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451999%2fphp-source-query-works-on-localhost-but-not-on-server%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini