Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Server Query killing script - No errors (PHP)
    primarykey
    data
    text
    <p>I'm running a simple PHP script to take some queries from a remote SQL Server. I have 3 queries in total, and 1 MySQL query. The first SQL Server query works fine, returns what I expect and so onto the next, $orders. Here the script stops dead. I mean no further output is rendered to the browser, the view-source of the result just stops at before the block of PHP starting with the $orders query.</p> <p>There are no errors in my apache log, error_logs or anywhere else I can find. I've also displayed get_last_message for mssql and it displays nothing. ANYTHING typed or echo'd after the second mssql_query(); is not working and the script just stops. There is no timeout and it is very quick to load. I've run the same query manually in SQL Server and it returns a result.</p> <p>Help?</p> <pre><code> &lt;?php // CHECK IF USER LOGGED IN session_start(); if ($_SESSION['loggedIn'] != "true") { header("Location: /reps/"); } // GRAB DATABASE DETAILS require('../assets/mssql_connect.php'); require('../assets/connect.php'); // SET GLOBAL REP VARIABLES $rep = $_SESSION['name']; $admin = $_SESSION['id']; $customer = $_GET['id']; $code = $_POST['Code']; ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;link rel="stylesheet" type="text/css" href="../assets/css/dashstyles.css" /&gt; &lt;script language="javascript" src="/reps/assets/js/formvalidation.js"&gt;&lt;/script&gt; &lt;title&gt;Reps Dashboard - &lt;?php echo $rep; ?&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php // GET HEADER INCLUDE require('../assets/header.php'); // BUILD QUERY USING ID TO GET FIELDS $edit = mssql_query("SELECT * FROM Customers WHERE ID='$customer'") or die(mssql_get_last_message()); while ($row = mssql_fetch_array($edit)) { $code = $row['Code']; $name = $row['Name']; $address = $row['Address'] . "&lt;br /&gt;" . $row['Town'] . "&lt;br/&gt;" . $row['County'] . "&lt;br /&gt;" . $row['Postcode']; $phone = $row['Tel']; $fax = $row['Fax']; } mssql_free_result($edit); ?&gt; &lt;div id="main"&gt; &lt;p class="welcome"&gt;Customer Detail: &lt;?php echo $name; ?&gt;&lt;/p&gt;&lt;p class="backlink"&gt;&lt;img src="../assets/images/icons/back_icon.png" alt="Back" /&gt;&amp;nbsp;&lt;a class="backlink" href="/reps/dashboard/"&gt;Back to dashboard&lt;/a&gt;&lt;/p&gt; &lt;table class="data"&gt; &lt;tr&gt; &lt;td style="width:40%"&gt; &lt;table class="data" style="width:100%"&gt; &lt;tr class="theader"&gt; &lt;td&gt;Customer Details&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;p&gt;&lt;b&gt;Customer Code: &lt;/b&gt;&lt;?php echo $code; ?&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;Address:&lt;/b&gt;&lt;br /&gt;&lt;?php echo $name . "&lt;br /&gt;" . $address; ?&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;Tel: &lt;/b&gt;&lt;?php echo $phone . "&lt;br /&gt;&lt;b&gt;Fax: &lt;/b&gt;" . $fax; ?&gt;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;td style="width:60%"&gt; &lt;table class="data" style="width:100%"&gt; &lt;tr class="theader"&gt; &lt;td&gt;Customer Orders History&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;?php require('../assets/mssql_connect.php'); // BUILD NEW QUERY FOR ORDERS $orders = mssql_query("SELECT TOP 10 * FROM MainJobDetails WHERE InvoiceCustomerCode='$code'") or die(mssql_get_last_message($orders)); // CHECK FOR 0 RECORDS if(mssql_num_rows($orders) == 0) { echo "No previous orders found."; } else { //OUTPUT PREVIOUS ORDERS echo "Last 10 Orders&lt;br /&gt;"; echo "&lt;table class='orders'&gt;"; echo "&lt;tr&gt;&lt;td&gt;Date&lt;/td&gt;&lt;td&gt;Job Number&lt;/td&gt;&lt;td&gt;Description&lt;/td&gt;&lt;td&gt;Status&lt;/td&gt;&lt;td&gt;Value&lt;/td&gt;&lt;/tr&gt;"; // ALTERNATE ROW COLOURS $c = 0; while ($row = mssql_fetch_array($orders)) { $class = $c++ % 2 == 1 ? "odd" : "even"; echo "&lt;tr class='$class'&gt;&lt;td&gt;"; echo $row['CreateDateTime']; echo "&lt;/td&gt;&lt;td&gt;"; echo $row['JobNo']; echo "&lt;/td&gt;&lt;td&gt;"; echo $row['JobDesc']; echo "&lt;/td&gt;&lt;td&gt;"; echo $row['Description']; echo "&lt;/td&gt;&lt;td&gt;"; echo $row['PriceEst']; echo "&lt;/td&gt;&lt;/tr&gt;"; } echo "&lt;/table&gt;"; } mssql_free_result($orders); ?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="width:40%"&gt; &lt;table class="data" style="width:100%"&gt; &lt;tr class="theader"&gt; &lt;td&gt;Comments Log&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;?php // GET CURRENT COMMENTS $comments = mysql_query("SELECT * FROM comments WHERE customer_id='$customer' ORDER BY id DESC LIMIT 0,5") or die(mysql_error()); // CHECK FOR 0 COMMENTS if(mysql_num_rows($comments) == 0) { echo "&lt;p&gt;No comments about this customer.&lt;/p&gt;"; } // LOOP THROUGH PREVIOUS COMMENTS while ($row = mysql_fetch_array($comments)) { echo "&lt;p style='line-height:20px;'&gt;&lt;b&gt;" . $row['rep'] . "&lt;/b&gt; &lt;i&gt;(" . $row['date'] . " at " . $row['time'] . ")&lt;/i&gt;&lt;br /&gt;"; echo $row['comment'] . "&lt;/p&gt;"; } ?&gt; &lt;form method="POST" name="comments" action="../assets/comment_post.php" onsubmit="return validateCForm();"&gt; &lt;textarea rows="10" cols="45" name="comment_box"&gt;&lt;/textarea&gt;&lt;br /&gt; &lt;input type="hidden" name="comment_date" value="&lt;?php echo date('d.m.Y'); ?&gt;"&gt; &lt;input type="hidden" name="comment_time" value="&lt;?php echo date('H:i:s'); ?&gt;"&gt; &lt;input type="hidden" name="id" value="&lt;?php echo $customer; ?&gt;"&gt; &lt;input type="hidden" name="rep" value="&lt;?php echo $rep; ?&gt;"&gt;&lt;br /&gt; &lt;input type="submit" class="search" name="submit" value="Post Comment"&gt; &lt;/form&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;td style="width:60%"&gt; &lt;table class="data" style="width:100%"&gt; &lt;tr class="theader"&gt; &lt;td&gt;Customer Estimates History&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;?php // BUILD NEW QUERY FOR QUOTES $quotes = mssql_query("SELECT * FROM MainEstimateDetails WHERE CustomerRef = '$code' ORDER by EstimateDate DESC LIMIT 0,10") or die (mssql_error()); // CHECK FOR 0 QUOTES if(mssql_num_rows($quotes) == 0) { echo "No previous quotes found."; } else { // OUTPUT PREVIOUS ORDERS echo "&lt;table class='orders'&gt;"; echo "&lt;tr&gt;&lt;td&gt;Date&lt;/td&gt;&lt;td&gt;Job Number&lt;/td&gt;&lt;td&gt;Description&lt;/td&gt;&lt;td&gt;Status&lt;/td&gt;&lt;td&gt;Value&lt;/td&gt;&lt;/tr&gt;"; // ALTERNATE ROW COLOURS $c = 0; while ($row = mssql_fetch_array($quotes)) { $class = $c++ % 2 == 1 ? "odd" : "even"; echo "&lt;tr class='$class'&gt;&lt;td&gt;"; echo $row['CreateDateTime']; echo "&lt;/td&gt;&lt;td&gt;"; echo $row['JobNo']; echo "&lt;/td&gt;&lt;td&gt;"; echo $row['JobDesc']; echo "&lt;/td&gt;&lt;td&gt;"; echo $row['description']; echo "&lt;/td&gt;&lt;td&gt;"; echo $row['PriceEst']; echo "&lt;/td&gt;&lt;/tr&gt;"; } echo "&lt;/table&gt;"; } ?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload