Can someone help me to find what is wrong in the $secret
line ?
$secret
should give :
{"name":"JustAname","extra":"1","password":"ASD123","report":"http:\/\/website.com\/dev\/gamereport\/0001.php"}
here's the PHP code:
<?php
date_default_timezone_set('America/Montreal');
$name = 'JustAname';
$extra = '1';
$password = 'ASD123';
$reception = 'http:\/\/website.com\/dev\/gamereport.php';
// Code de génération de la base64
$secret = '{"name":"'.$name'","extra":"'.$extra'","password":"'.$password'","report":"'.$reception'"}';
$encodedSecret = base64_encode($secret);
$tournementLink = 'pvpnet://lol/customgame/joinorcreate/map1/pick6/team5/specALL/'.$encodedSecret;
echo $tournementLink;
?>
I got: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in [...] on line 20
You're incorrectly concatenating strings, as @hobbs suggests. You're also using the undefined variable $Tournament
, which I think should be $name
. Try this:
$secret = '{"name":"' . $name . '","extra":"' . $extra . '","password":"' . $password . '","report":"' . $reception . '"}';
On a side note, a slightly nicer way to create JSON in PHP is to use an array and json_encode()
:
$secret = json_encode(array(
'name' => $name,
'extra' => $extra,
'password' => $password,
'report' => $reception));