skip to Main Content

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->
    ]

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

2

Answers


  1. This

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

    Means a href which includes /tickets/tickets/, followed by whatever value (presumably numeric) $o->id has, followed by /?, ending the effective part of the URL which specifies where to send the request and the ? here states that the query string comes, where you will have key=value pairs, separated by & ampersands. So, access_token is part of the query string and represents a GET parameter (which you will be able to reach via $_GET['access_token']) in your PHP code) and the value of this would be whatever you describe, presumably $o->access_token or something of the like. Your code is broken for not having a proper enclosing for your <? which is a syntax to hand over the initiative to PHP to type in something into the template, as PHP is a templating language. So you will need to figure out what $o is and fix the code above to something like

    href="/tickets/tickets/<?=$o->id?>/?access_token=<?=$o->access_token?>
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search