Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I've written a small code that get $_GET["page"] and if this exists, write the page $_GET["page"] . ".html" into a div (with echo). If this not exists, the page is "about.html". The problem is that and I've searched but I don't find the solution...
Fatal error: Function name must be a string in index.php on line 63.
If i go into a page that don't exists (for exampleindex.php?page=test) work (print "NOT FOUND") but if I go into a page that exists (for example index.php?page=about or simply index.php) don't work.
This is the code:
$page = "about";
if (isset($_GET["page"]))
if (!empty($_GET["page"]))
$page = $_GET["page"];
$page .= ".html";
$result = "NOT FOUND";
if (file_exists($page))
$result = $file_get_contents($page); //line 63
echo $result;
file_get_contents() not $file_get_contents()
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I'm trying to access the $_GET array in PHP like so:
<?php
$incl = $_GET("incl");
if ( $incl == "" ) { $incl = "home"; }
Whenever I access the script, I get a 500 error. Any idea why?
If you get an unexpected HTTP 500 error that you haven't sent yourself from PHP, this means there's an actual error in your script.
In this case, your problem is this line:
$incl = $_GET("incl");
$_GET is an array, so when you want to access values within it by key, you need to do so with [], not ():
$incl = $_GET['incl'];
Further, your check for $incl being empty should look like this:
if(empty($_GET['incl']){
$incl = 'home';
} else {
$incl = $_GET['incl'];
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Okay this really strange or I am missing something. When I run this very simmple PHP script on cmd I get the expected output which is 0. but when I uncomment the last two lines of code. . .nothing is displayed.
<?php
$test1 = 0;
echo $test1;
$test2 = 0;
#$test1_weight = 0:
#$test2_weight = 0;
?>
Is there some rule against declaring variables after an echo statement?
$test1_weight = 0:
--> change ":" to ";"
No there is no rule against declaring variables after an echo statement
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
My site was hacked and I found on it the
<?php
echo eval(base64_decode(str_replace('*','a',str_replace('%','B',str_replace('~','F',str_replace('_','z',str_replace('$','x',str_replace('#','d',str_replace('^','3','SOMEVERYLONGTEXT')))))))));
if I decode base64 without executing, I got some script, starting with:
$__authentication_pass = "52b1d005abc139cc281a32d8aa7cd1c2";
$color = "#df5";
$__default__action = 'FilesMan';
$default_use_ajax = true;
$default_charset = 'Windows-1251';
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
$userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler");
if (preg_match('/' . implode('|', $userAgents) . '/i', $_SERVER['HTTP_USER_AGENT'])) {
header('HTTP/1.0 404 Not Found');
exit;
}
}
#ini_set('error_log', NULL);
.... and many lines below ....
I this file manager? Can it be identified somehow (name, author and so on)?
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I'm currently having an issue with simplexml_load_file(); my xml path is a url, that is rendered as a variable
$xurl = "domain/pathto/myfile.xml"; // This is actually a variable that returns the entire URL to where my xml file is -- this will change from file to file
$xmlpath = parse_url($xurl, PHP_URL_PATH); // to get the path of my xml file ex. /pathto/myfile.xml
$xmlpath = mb_substr($xmlpath, 1); // returns pathto/myfile.xml
here is where my problem is, when I put it into :
simplexml_load_file($xmlpath);
In my function, I get nothing appearing from the XML file
However, in my same function if I change it to
simplexml_load_file("pathto/myfile.xml");
My function works fine.
I did an echo on $xmlpath and it returns the pathto/myfile.xml just fine.
<?php echo $xmlpath; ?> // returns pathto/myfile.xml
What am I doing wrong?
EDIT: Phil
echo strcmp("pathto/myfile.xml", $xmlpath)
returns a 0.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have a messages page that loads communications between two users. The URL is message.php?u=[me]&p=[message parent id]&op=[other person], but $p and $op are not being defined in the page. When I echo each variable separately, $u appears everywhere from pre tag to the bottom of the document, but $p and $op do not echo anywhere. I tried deleting everything in .htaccess to see if that was causing a bug, but it wasn't. I can't think of what would cause this.
yourscript.php?var1=value1&var2=value2
You can use this by:
$var1 = $_GET['var1']; // $var1 = 'value1'
$var2 = $_GET['var2']; // $var2 = 'value2'
You can check whether or not these URL-parameters are set with isset()
(otherwise you create errors when you do not set them):
if (isset($_GET['var1'])) {
$var1 = $_GET['var1'];
} else {
die('usage: yourscript.php?var1=value1 !');
}