How to fix an error in a php variable? Server gives 500 error


I have a code that is responsible for add money to account. There are tariff plans on the page of the site, when you click pay, the user switches to paying the bill. The code is as follows:

   public function pay(Request $request)
        $ticketID = $request->get('tickID');
        if($ticketID = 1){
            $sum = 32;
        }elseif($ticketID = 2){
            $sum = 64;
        }elseif($ticketID = 3){
            $sum = 320;
        }elseif($ticketID = 4){
            $sum = 640;
        }elseif($ticketID = 5){
            $sum = 1600;
        }elseif($ticketID = 6){
            $sum = 3840;
        }elseif($ticketID = 7){
            $sum = 6400;
        }elseif($ticketID = 8){
            $sum = 9600;
        $u = $this->user->steamid64;
        $merchant_id = '423';
        $secret_word1 = '432';
        $sign = md5($merchant_id.':'.$sum.':'.$secret_word1.':'.$u);
        $url = ''.$merchant_id.'&oa='.$sum.'&o='.$u.'&s='.$sign.'&lang=ru&i=&em=';
        $returnValue = [
            'redirect' => $url
        return $returnValue;

    function getIP() {

        if (isset($_SERVER['HTTP_X_REAL_IP'])) return $_SERVER['HTTP_X_REAL_IP'];

        return $_SERVER['REMOTE_ADDR'];


    public function payaccept(Request $request)
        $merchant_id = '534';
        $secret_word2 = '423423';

        if (!in_array(getIP(), array('', '', ''))) die('hacking attempt!');

        $sign = md5($merchant_id.':'.$_REQUEST['AMOUNT'].':'.$merchant_secret_2.':'.$_REQUEST['MERCHANT_ORDER_ID']);

        if ($sign != $_REQUEST['SIGN']) die('wrong sign');
        $summ = $_REQUEST['AMOUNT'];
        $user = User::Where('steamid64',$_REQUEST['MERCHANT_ORDER_ID']);
        if ($summ = 32) {
            $user->money += $summ;
        }elseif ($summ = 64) {
            $user->money += $summ;
        }elseif ($summ = 320) {
            $user->money += $summ;
        }elseif ($summ = 640) {
            $user->money += round($summ*1.03);
        }elseif ($summ = 1600) {
            $user->money += round($summ*1.05);
        }elseif ($summ = 3840) {
            $user->money += round($summ*1.1);
        }elseif ($summ = 6400) {
            $user->money += round($summ*1.15);
        }elseif ($summ = 9600) {
            $user->money += round($summ*2);


Function pay forms a link, amount and digital signature. Function payaccept the function processes the payment and must enter payment information into the database.

The problem is in line $user = User::Where('steamid64',$_REQUEST['MERCHANT_ORDER_ID']); i know it with help var_dump().

This line produces a variable steamid64, but can't fint in a DB. How i can fix it?

Kenny Horna

Well, given that you haven't put any error message or log.. I assume the error is this line:

$user = User::Where('steamid64',$_REQUEST['MERCHANT_ORDER_ID']);

Here you are creating the query... but not executing it. To do so add ->first() at the end.

$user = User::Where('steamid64',$_REQUEST['MERCHANT_ORDER_ID'])->first();

Then you will be able to call methods on the $user object.

Collected from the Internet

Please contact javaer1[email protected] to delete if infringement.

edited at


Login to comment


PHP MySql insert gives server error 500

How can i fix internal server error?HTTP ERROR:500

500 internal server error php, how to solve?

How to fix server error 500 web api in mobile app

How to fix an unknown internal server error (500) Nginx is giving me?

How to fix 500 internal server error while using Django and React

How to fix " HTTP Status 500 – Internal Server Error "

Creating symlink gives 500 Internal Server Error

PHP error undefined variable notice how to fix?

Jupyer lab gives Error 500: Internal Server Error

Ajax call to webmethod gives ERROR 500 Internal server error

Unexplained PHP error (Internal Server Error 500)

After hosting to server symfony gives 500 internal server error

How to fix HTTP ERROR 500 cpanel - laravel

NumPy package gives an array() error how to fix this?

How to fix that ToString() gives out error with an int?

simple AJAX JQuery example gives me 500 internal server error

Server gives 500 code error but still serves content

Selenium gives Server Error 500 after click (Django, pytest)

Django, nginx, gunicorn: why on some page gives Server Error (500)?

Excel/PowerBI OData import gives internal server error 500

ExpressJS API Deployed on Heroku Gives 500 Internal Server Error

Htaccess rewrite url gives 500 Internal server error

Apache server mod_wsgi in Redhat gives 500 error

htaccess error 500 if empty variable (php)

How to fix this SQL Server error?

sql data to json array using PHP gives HTTP ERROR 500 MVC login script gives a 500 error

PHP use keyword is causing 500 server error