Let user select the number of posts shown per page jquery error

A simple fix would be to change the query name; i.e. from page to pageVal.

<script>
jQuery(document).ready(function( $ ) {
  $('.page-select').change(function(){
    var checkIndex = ( window.location.href || '' ).indexOf('?');
    if( checkIndex > -1 ){
      var Link = window.location.href.substr(0, checkIndex-1);
      $(location).attr('href', Link+'?pageVal="+$(".page-select').val());
    } else {
      $(location).attr('href', window.location.href+'?pageVal="+$(".page-select').val());
    }
  });

});
</script>

But I’d use this..:

<script>
jQuery(document).ready(function( $ ) {
  $('.page-select').change(function(){
    var url = window.location.href || '',
      has_q = ( url.indexOf( '?' ) > -1 );

    if ( url.indexOf( '?pageVal=" ) > -1 ) {
      url = url.replace( /\?pageVal=\d+/, "?pageVal=" + this.value );
    } else if ( has_q && url.indexOf( "&pageVal=" ) > -1 ) {
      url = url.replace( /&pageVal=\d+/, "&pageVal=" + this.value );
    } else {
      url = url + ( has_q ? "&' : '?' ) + 'pageVal=" + this.value;
    }

    window.location.href = url;
  });

});
</script>

Additional Note

I”d also change the select to:

<select id="news-posts-per-page" class="page-select"><?php
  // List of "posts per page" options.
  $per_pages = [ 10, 20, 30 ];

  foreach ( $per_pages as $n ) {
    $selected = selected( $n, $showposts, false );
    printf( '<option value="%d"%s>%d</option>',
      $n, $selected, $n );
  }
?></select>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)