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
function me1($str) {
$hash = 'http://me1.wink.ws/me1/request.php?a=' . $str;
return $hash
}
$hi = me1('Hi');
?>
Where is my error?
Parse error: syntax error, unexpected '}' in /home/u727762781/public_html/client/me1.php on line 5
Fixed Code:
<?php
header('Content-Type: text/plain');
function me1($str) {
$hash = file_get_contents('http://me1.wink.ws/me1/request.php?a=' . $str);
return $hash;
}
$hi = me1('Hi');
echo $hi;
?>
You forgot the semi-colon at the end of the return statement.
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 3 years ago.
Improve this question
I want to compare two arrays with each other with this code:
if($jobids !== null){
if (isset($_COOKIE["djsearchquery"])){
$cookiequery[] = unserialize($_COOKIE['djsearchquery']);
$arrayequal = ($cookiequery == $jobids);
$consolelog = $cookiequery;
$consolelog[] = $jobids;
$consolelog[] = $arrayequal;
if($arrayequal == false){
$response = array(
'jobids' => $jobids,
'markerpositions' => $markerpositions,
'consolelog' => $consolelog
);
setcookie('djsearchquery', serialize($jobids), time()+3600);
echo json_encode($response);
}
}
In the console the arrays are pictured exactly the same:
Can someone explain to me why $arrayequal returns false? I donĀ“t understand it.
try to change
$cookiequery[] = unserialize($_COOKIE['djsearchquery']);
to
$cookiequery = unserialize($_COOKIE['djsearchquery']);
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 use #if & #else inside a controller, eg:
public function deleteCharacter ($char_delete_id)
{
#if (Auth::user()->id == $delCharacterUserID)
$deleteSuccess = 1;
return redirect('/characters')->with('deleteSuccess', $deleteSuccess);
#else
$deleteSuccess = 0;
return redirect('/characters')->with('deleteSuccess', $deleteSuccess);
#endif
This throws the error:
FatalErrorException in CharacterController.php line 40: syntax error,
unexpected 'if' (T_IF)
In a controller, just use the normal PHP syntax, not blade syntax. So replace your code by:
public function deleteCharacter ($char_delete_id)
{
if (Auth::user()->id == $delCharacterUserID) {
$deleteSuccess = 1;
} else {
$deleteSuccess = 0;
}
return redirect('/characters')->with('deleteSuccess', $deleteSuccess);
}
And it should work! A controller is a PHP file, so write PHP in it.
Optimize your code like that
public function deleteCharacter ($char_delete_id)
{
$deleteSuccess = Auth::user()->id == $delCharacterUserID?1:0;
return redirect('/characters')->with('deleteSuccess', $deleteSuccess);
}
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
I tried to echo out the $rinse variable, I get nothing
But I do get one for the $rang['email'], any clues would be good
I also tried doing $rinse == $rang['email'];
while($rang = mysql_fetch_assoc($results))
{
if ($rang['email'] = $rinse){
echo $rang['email'];
}
$rinse = $rang['email'];
}
my code updated:
echo $rinse;
if ($rang['email'] == $rinse){
echo $rang['email'];
}
$rinse = $rang['email']
This is still not working for me
You need two = in your if statement.
if ($rang['email'] == $rinse){
You should add double ==. This is comparion, a single = means set to
while($rang = mysql_fetch_assoc($results))
{
if ($rang['email'] == $rinse){
echo $rang['email'];
}
$rinse = $rang['email'];
}
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 having trouble making a empty string to have something inside, I'm also removing some other unnecessary characters from that string which works.
$desc = strip_tags($mapAnnotationArray);
$mapAnnotationArrayOutput = str_replace( array('"', '(' , ')'), '', $desc);
$mapAnnotationArrayOutput = trim($mapAnnotationArrayOutput);
if(empty($mapAnnotationArrayOutput)) {
($mapAnnotationArrayOutput == "empty");
}
Change this
($mapAnnotationArrayOutput == "empty");
To this
$mapAnnotationArrayOutput = "empty";
I've seen many people write:
if( x = "foo")
and wonder why it assigns "foo" to x... but never the other way around.
if( !$mapAnnotationArrayOutput) $mapAnnotationArrayOutput = "empty";
Try putting:
print("String is empty");
In the if statement, at the moment ($mapAnnotationArrayOutput == "empty"); will have no output so you wouldn't know if the string was empty or not.
If you're trying to assign the variable the value of "empty", use:
$mapAnnotationArrayOutput = "empty";
Instead.
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 have a following simple code but it produces syntax error on line this->players[] = 'Tom':
<?php
class club {
var $clubID = 0;
var $players=array();
function __constructor($clubID = '') {
$this->clubID = $clubID;
}
function populatePlayers() {
$this->players[] = 'Tom';
}
}
$myClub = new club(1);
$myClub->populatePlayers();
var_dump($myClub->players);
?>
It should be
$this->players[] = 'Tom';
instead of
$this->$players[] = 'Tom';
You need to add $ before the this keyword and the players variable does not need one.
Demo
try this
function populatePlayers() {
$this->players[] = 'Tom';
}