Ajax, PHP, SQL, and JavaScript -


i ran issue cannot find answer, ask questions here, rather stumped. assistance shall appreciated.

this php receives ajax call.

<?php     session_start();     $_session["my_data"] = $_post['action'];      $db_hostname = 'localhost';     $db_username = 'username';     $db_password = 'password';      $link2 = mysqli_connect($db_hostname,$db_username,$db_password) or die('unable establish db1 connection');     mysqli_select_db($link2, '$db_username');      $orderquery = mysqli_query($link2, "select * table id='".$_session['my_data']."'");     $orderquery = mysqli_fetch_assoc($orderquery);      $orderinfo = "         <table class='table table-striped'>         <tbody>             <tr>                 <td>#: </td>                 <td>". $_session['my_data'] ."</td>             </tr>             <tr>                 <td> full name: </td>                 <td>". $orderquery['firstname'] . " " . $orderquery['lastname'] ."</td>             </tr>             <tr>                 <td> address: </td>                 <td> ". $orderquery['shipping_address_1'] ."<br> ". $orderquery['shipping_city'] . " " . $orderquery['shipping_zone'] . " " . $orderquery['shipping_postcode'] ." </td>             </tr>             <tr>                 <td> card expiry date month: </td>                 <td> 08 </td>             </tr>                 </tbody>     </table><br>     ";      echo $orderinfo/* . $_post['action']*/;   ?> 

and script makes call.

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>     <script>      var mywindow;     function myfunction() {     mywindow = window.open('', '_blank');     mywindow.document.write("<link rel='stylesheet' type='text/css' href='stylesheet.css'>");      var ordernum;     ordernum = document.getelementsbyclassname('summary_value')[0].innerhtml;     ordernum = ordernum.replace("#", "");      $.ajax( { type : 'post',       data : {'action':ordernum},       url  : 'process.php',       success: function ( data ) {         mywindow.document.write( data );       },       error: function ( xhr ) {         alert( "error" );       }     });      mywindow.document.write("<br>");     mywindow.document.write(document.getelementbyid("payinfor").innerhtml);     }  </script> <button onclick='myfunction()' class="btn btn-default">print pay info</button> 

it simple issue, can't see it.

i know ajax working because displays of information ($_session['my_data']), thinking it's sql statements, syntax looks correct.

mysqli_select_db() expects parameter 1 connection , parameter 2 database name. in case passing '$db_username'. code connect database named '$db_username' because of single quotes. change database name instead. either $db_name or 'database_name' should work. while in development mode, try enabling error_reporting(e_all) catch errors this.


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -