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
<?php
require("whoisClass.php")
$whois=new Whois;
$rs=$whois->whoislookup("99webtools.com"); //Your domain or IP
echo '<pre>'.$rs.'</pre>';
?>
and this is link to show whoisclass.php
http://99webtools.com/php-whois-script.php
The script has an error which you also have (copied and pasted from source), being the missing semi-colon at the end of:
require("whoisClass.php")
^ // <= right there
replace with:
require("whoisClass.php");
and it will run.
Having error reporting on, would have signaled the following error:
Parse error: syntax error, unexpected '$whois' (T_VARIABLE) in /user/home/whois.php on line 3
Always use error reporting:
error_reporting(E_ALL);
ini_set('display_errors', 1);
http://php.net/manual/en/function.error-reporting.php
Footnotes:
When an error is reported on a certain line number, many times the error is on the line before that. In this case it signals being on line 3, yet it's actually on line 2.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
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.
Improve this question
I have a PHP file wherein I'm trying to set a cookie; here is the code:
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$coname = ‘logged’;
$coval = ‘false’;
setcookie($coname,$coval);
?>
Logged is the name of the cookie, false is the value. Right off the bat it's throwing:
Notice: Use of undefined constant ‘logged’ - assumed '‘logged’' in (path) on line 4
Notice: Use of undefined constant ‘false’ - assumed '‘false’' in (path) on line 5
It appears to be reading these strings as constants, then. Every resource I can find recommends solving this by enclosing the string in quotes, which I've tried with both single and double quotes to no avail. If anyone knows why the error persists, it would be a huge help. Thanks!
You're using back- and forward-ticks instead of single quotation marks, so PHP is trying to interpret ‘logged’ and ‘false’ as constants, which aren't defined.
Try this instead:
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$coname = 'logged';
$coval = 'false';
setcookie($coname,$coval);
?>
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 7 years ago.
Improve this question
Since installing Mac OSX El Capitain, I am getting a parse error. The code works fine on the server, but on my development workstation, I get this error consistently.
Parse error: parse error in /Library/WebServer/Documents/website/includes/config.php on line 4
// Calling code snippet:
include("includes/navbar.php");
require_once("includes/config.php");
$servername = DBHOST;
$username = DBUSER;
$password = DBPASS;
$database = DBNAME;
config.php file:
<?php
/* Config File for Common Values */
define ("DBHOST", “127.0.0.1:3306”); <--- This is line 4
define ("DBUSER", “userid”);
define ("DBPASS", “password”);
define ("DBNAME", “database”);
?>
You're using smart quotes (“ and ”) where you should have straight quotes ("). Replace the smart quotes with straight quotes. For example, change
“127.0.0.1:3306”
to
"127.0.0.1:3306"
Do the same with each of the other define() statements.
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'm trying to exclude links in a PHP spider. Here is the block that is returning the error
// Exclude links in exclusion array
for($xx=0; $xx<count($exclusion_array); $xx++)
{
if(stristr($link, $exclusion_array[$xx]))
{
echo "Ignored excluded link : $link\n";
$exclude=true
break;
}
}
What am I doing wrong here? Is there perhaps a problem somewhere else that could make this "unexpected break" error show up?
You missed a terminating semi clone (;) after $exclude=true;.
if(stristr($link, $exclusion_array[$xx])) {
echo "Ignored excluded link : $link\n";
$exclude=true;
^^^
break;
}
$exclude=true // You are missing a semi-colon here.
add a semi-colon like this
$exclude=true;
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
Here is my code inside of a function:
list(${$page}Records, ${$page}MetaData) = getRecords(array(
'tableName' => $page,
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
Problem is, the very first line of it throws this error :
Parse error: syntax error, unexpected T_STRING, expecting ',' or ')' in /[edited]/includes/functions.php on line 10
I've tried a bunch of different ways of going about this but I don't know much about PHP. Anyone know what's going on here?
${$page}Records
This is not how you use variable variables. PHP has no idea what you mean with Records there.
Try this:
${$page.'Records'}
PHP will run the code inside the {} and use that string as a variable name.
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
Why is it that in PHP 5.3.8:
$obj->foo()['bar']; // syntax error
$obj->foo()->['bar']; // valid
But in PHP 5.4.9 it's reverse:
$obj->foo()['bar']; // valid
$obj->foo()->['bar'] // syntax error
$obj->foo()['bar']; is valid in PHP >= 5.4.0
$obj->foo()->['bar'] is not valid in any version even if you add the required ;
So in versions before 5.4.0 you will get a parse error on the first line that will stop execution and not show the parse error on the next line.
In versions 5.4.0 and greater the first line works but you get a parse error on the second. So if you reverse them, you will always get the parse error for $obj->foo()->['bar'] in any version.
Example $obj->foo()->['bar'] was never valid, in any PHP version; see here.
Maybe you got it mistaken with syntax like $obj->foo()->{'bar'}; see here.
Example $obj->foo()['bar'] is valid from PHP >= 5.4.0; see here.
Support for
$obj->foo()['bar'];
came in PHP 5.4.0 as support for function array dereferencing was added only from that version.
This useful page explains it:
https://wiki.php.net/rfc/functionarraydereferencing
Your first example has never been valid.
$obj->foo()->['bar']; // is invalid in any PHP implementation
However with method chaining support: if $obj->foo() returns an object with a bar property this will work:
$obj->foo()->bar;