cruex

cruex

Member Since 1 Year Ago

Experience Points 11,920
Experience Level 3

3,080 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 118
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

11 Oct
10 months ago

cruex left a reply on Save() Use Wrong DB_HOST But The Correct DB_USER

Illuminate/Database/QueryException with message 'SQLSTATE[42000]: Syntax error or access violation: 1142 UPDATE command denied to user 'database_user'@'WRONGSERVERIP' for table 'table_name' (SQL: update table_name set email_verified = 1, updated_at = 2018-10-11 21:28:06 where id = 2)'

UPDATE command denied to user 'database_user'@'WRONGSERVERIP'

in the error log: "WRONGSERVERIP" was the ipv4 address from the production server

and the external db server working perfect with no error

cruex left a reply on Save() Use Wrong DB_HOST But The Correct DB_USER

Yes, I am aware of that, but what is the point if I check the rights on the production server if he should not access it at all? The system is supposed to access the externally hosted database. And right now, he's trying to access the local database. But it's just this one function that confuses me.

cruex left a reply on Save() Use Wrong DB_HOST But The Correct DB_USER

There is no database service installed on the Production server.

The Model:

class Subscriber extends Model
{
    protected $table = 'newsletter_subscribers';

    protected $fillable = [
        'user_id', 'lang', 'email', 'email_verified', 'email_token'
    ];
}

This is the post function in the controller:

    public function verifyPost($token)
    {
        $verify = Subscriber::where('email_token', $token)->first();
        $generateToken = generateToken();

        $verify->email_verified = 1;
        $verify->email_token = $generateToken;
        $verify->save();

        return redirect( route('welcome'));
    }

any error or syntax error? (generateToken() is a helper function)

cruex left a reply on Save() Use Wrong DB_HOST But The Correct DB_USER

The database has enough rights, otherwise I couldn't have anything created. And the query doesn't help me, because he uses the wrong IP from the Database server. But thanks for your help and ideas.

cruex left a reply on Save() Use Wrong DB_HOST But The Correct DB_USER

Quotes from the values in the .env change have no effect...

Array from the thinker looks okay, IP is set and all another vars.

I have not defined a connection on a DB query builder or in an Eloquent model...

I'm a little confused. ^^'

cruex left a reply on Save() Use Wrong DB_HOST But The Correct DB_USER

.env

DB_CONNECTION="mysql"
DB_HOST="XX.XX.XX.XX"
DB_PORT="3306"
DB_DATABASE="db"
DB_USERNAME="usr"
DB_PASSWORD="XXXXXXXXXXXXXXX"

config/database.php

'connections' => [
    'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
        ],
],

Reading and creating works in the database, only save() and update() makes the mistake so far.

and yes i run config:clear & cache:clear

cruex left a reply on Save() Use Wrong DB_HOST But The Correct DB_USER

Yes only 1 Database and the driver is MySQL and the .env file with the Database Settings are correct

cruex started a new conversation Save() Use Wrong DB_HOST But The Correct DB_USER

Hello,

I have a weird bug and I can't find a solution to it, namely:

I host my website with the Forge Service, my database is on an external server, now to my problem.

I'm trying with a "post" function to change a value in the database to verify an email, the values it can read out problem without error, but as soon as I get a value like

$verify->email_verified = 1;
$verify->save();

as an example, he takes the IP address of the web server and tries to connect to it, only now the problem my database is on an external server. This also works and you can read or enter values (with create etc.), only with this save() and update(); value edits it wrong.

ERROR:

Illuminate/Database/QueryException with message 'SQLSTATE[42000]: Syntax error or access violation: 1142 UPDATE command denied to user 'database_user'@'WRONGSERVERIP' for table 'table_name' (SQL: update `table_name` set `email_verified` = 1, `updated_at` = 2018-10-11 21:28:06 where `id` = 2)'

I hope someone can help me.