Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9141319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:37:46+00:00 2026-06-17T09:37:46+00:00

I constantly get 500 Internal Server Error while trying to query a db. The

  • 0

I constantly get 500 Internal Server Error while trying to query a db. The data is passed by Ajax to that specific page.

Here is the code:

<script type="text/javascript">

            $(document).ready(function(){
                    $(".pool-player-list-a").click(function(){
                        /* Prosleđujem parametre za upis u bazu na stranicu insert_tim.php */   
                        var id = $(this).next().val();
                        var br_dresa = $(this).next().next().val();
                        var zapisnik = <?php echo $zapisnik->id; ?>;
                        var mec = <?php echo $zapisnik->idMeca; ?>;

                        $.post('../wp-content/plugins/leaguemanager/admin/insert_tim.php', {id: id, zapisnik: zapisnik, mec: mec, br_dresa: br_dresa},

                    function(data){
                        $("#message").html(data);
                        $("#message").hide();
                        $("#message").fadeIn(500);
                    });
                    return false;
                });
            });

        </script>

        <div id='message'></div>

        <div id='pool-holder'>      

            <!-- Lista igrača iz domaćeg tima -->
            <div id="pool-home">
                <h3 style="margin:0; padding:10px;" align="center">DOMAĆI</h3>

                <?php

                    $igraci_home = $this->igraci_u_timu($league_id, $mec->home_team);

                    foreach ($igraci_home as $igrach){
                        /* Listam igrače */
                        echo "<div class='pool-player-list'>
                                <a class='pool-player-list-a' id='insertTim' href='#'>
                                    $igrach->ime $igrach->prezime
                                </a>
                                <input type='hidden' class='igracId' value='$igrach->id' />
                                <input type='hidden' class='brDresa' value='$igrach->brojDresa' />
                              </div>";
                    }

                ?>

            </div>

I have checked everything with the variables. Everything is fine.

And this is the insert_tim.php page that is sending Server Error.

<?php
global $wpdb;

$id = intval( $_POST['id'] );

$row = $wpdb->get_row("SELECT * FROM wp_pls_leaguemanager_person WHERE id = '$id'", ARRAY_A);

echo $row['ime'];

?>

It works on other pages.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:37:47+00:00Added an answer on June 17, 2026 at 9:37 am

    Please, read this post carefully about AJAX in WordPress plugins.

    You need to send AJAX requests to special script, not directly to your plugin! And then you handle request using actions.

    But what you have done? – You send request to your script, so it knows nothing about WordPress :). WordPress must include your plugin and then your plugin will have access to native functions and classes.

    Update. More detailed explanation.

    AJAX is just calling your script from given link. When you call your script directly (http://site.com/wp-content/plugins/myplugin/insert_tim.php), then php begins to execute it and NOTHING MORE! It doesn’t initiate WordPress engine. So $wpdb will be undefined variable that will throw exception on use (if exception display is disabled in your php config, then you will just see “Internal Server Error 500”). Of course, if you remove $wpdb usage – all will be OK.

    And what does WordPress’s ajaxurl (http://site.com/wp-admin/admin-ajax.php) change? If you will open this file – you will see, that it contains WordPress engine load:

    /** Load WordPress Bootstrap */
    require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
    

    So if you pass ajaxurl to your AJAX call – then this script will load WordPress engine, then using actions – will call your function and your function will see $wpdb class.

    Remember the rule: Don’t call your plugin’s PHP scripts directly using AJAX. Use native WordPress behavior.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn CodeIgniter, and I'm constantly running into 500, Internal Server Error.
In my WCF service, when trying transfer large data I constantly get an error:
I figured out that a constant literal get's placed in the data segment of
I constantly get this error using mako: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0'
I'm am trying to get jlembed to work but I constantly get errors in
I'm having some difficulty with managing an administration page, where I constantly get an
I am trying to parse PHP error log. The issue is that breaking the
I constantly get malloc error : double freed.... The echoTime function is being called
In Python, I'm constantly using the following sequence to get an integer value from
Using stock TomEE+, I cannot get a simple JAX-RS resource to work. I constantly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.