phphref

Problem with generating tickets for event


I am trying to move a PHP website from one host (Avlux, which is shutting down) to another (DreamHost). I am having problems with code that generates event tickets. At this point, I am running the system in WampServer using Visual Studio Code to edit the programs.

This is the html code for the link to "Print" the ticket:

href="/tickets/tickets/<?=$o->id?>/?access_token=<?=$o->access_token()?>"

And this is the function:

public function access_token() {
   return base64_encode($this->id + 'ClearSight Studio');
}    

The problem: On the old host, the ticket is generated. base64_encode creates a set of characters such as: NjA4NTQ and prints a ticket. On the new host, the hyperlink is not created and the program ends.

Question: What does the question mark in "/?access_token" mean?

What I have tried: I've tried isolating the code following tickets/tickets and running it standalone, but I can't seem to do that again without generating an error that seems to mess up the entire program in Visual Studio Code.

$o->id is an integer. When I was able to run the function, access_token standalone, it could not concatenate an integer with a string. So I converted it to a string, $str_id, and replaced id?> with


Solution

  • this code:

    base64_encode($this->id + 'ClearSight Studio');
    

    results in an error:

    PHP Warning: Uncaught TypeError: Unsupported operand types: string + int in php shell

    instead, to concatenate a string with an integer, write:

    base64_encode($this->id . 'ClearSight Studio');
    

    It seems you were unable to see the error message. In your php.ini, set:

    display_errors = On
    

    ... to see warnings and errors live during development. Make sure to remove this setting for production.