Data Not Pulling From Table

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Data Not Pulling From Table

Postby jzint1267 » 27. December 2012 17:05

I am having an issue with data not pulling from a table. The information is pulled via two files. The first is a form to capture tag numbers from inventory. The second is the actual tag. For some reason the file that creates the tag is not pulling the information from the database based on the tag numbers. I have a feeling that it is how the query is coded, but I am not having any luck. I am using a program called PHP Runner to aid in writing the code along with a lot of other custom coding. When I run the site and view from localhost, the information is there, but when I view the site from the IP address on a workstation, the information is gone, the table structure is gone, and the field headers are all at the top of the page and run together.

Below is the coding for the the page. Any help on this would greatly be appreciated.

<?php
ini_set("display_errors","1");
ini_set("display_startup_errors","1");


include("include/dbcommon.php");
include("include/_users_variables.php");

$filename="";
$message="";
$error_happened=false;
$readevalues=false;

//connect database
$conn = db_connect();

Function strempty($input)
{
if($input != '')
{
return $input;
}else{
$strrpl = "---";
return $strrpl;
}
}



?>
<link REL="stylesheet" href="include/style.css" type="text/css">
<html>

<body>

<?php
global $conn;
$query = "SELECT * FROM _equipment_in_stock Tag_ID, Type, Department, Attention, Category, Customer, Store_Number, Part_Number, Model_Number, Serial_Number, Color, Size, Description from _equipment_in_stock where Tag_ID BETWEEN '".$_POST['starttag']."' AND '".$_POST['endtag']."' ";
$result = mysql_query($query, $conn);
while ($row = mysql_fetch_array($result))
{
?>

<br>
<table border="2" width=100% cellspacing="2">
<tr bgcolor="#efefef">
<td width="33%" valign="top" align="center"><font size="5">TYPE</font></td>
<td width="33%" valign="top" align="center"><font size="5">DEPARTMENT</font></td>
<td width="33%" valign="top" align="center"><font size="5">ATTENTION</font></td>
</tr>
<tr>
<td height="70" valign="middle" align="center"><font size="5"><? echo $row['Type'];?></font></td>
<td height="70" valign="middle" align="center"><font size="5"><? echo $row['Department'];?></font></td>
<td height="70" valign="middle" align="center"><font size="5"><? echo $row['Attention'];?></font></td>
</tr>
<tr bgcolor="#efefef">
<td valign="top" align="center"><font size="5">CATEGORY</font></td>
<td valign="top" align="center"><font size="5">CUSTOMER</font></td>
<td valign="top" align="center"><font size="5">STORE NUMBER</font></td>
</tr>
<tr>
<td height="70" valign="middle" align="center"><font size="5"><? echo strempty($row['Category']);?></font></td>
<td height="70" valign="middle" align="center"><font size="5"><? echo strempty($row['Customer']);?></font></td>
<td height="70" valign="middle" align="center"><font size="5"><? echo strempty($row['Store_Number']);?></font></td>
</tr>
<tr bgcolor="#efefef">
<td valign="top" align="center"><font size="5">PART NUMBER</font></td>
<td valign="top" align="center"><font size="5">MODEL NUMBER</font></td>
<td valign="top" align="center"><font size="5">SERIAL NUMBER</font></td>
</tr>
<tr>
<td height="70" valign="middle" align="center"><font size="5"><? echo strempty($row['Part_Number']);?></font></td>
<td height="70" valign="middle" align="center"><font size="5"><? echo strempty($row['Model_Number']);?></font></td>
<td height="70" valign="middle" align="center"><font size="5"><? echo strempty($row['Serial_Number']);?></font></td>
</tr>
<tr bgcolor="#efefef">
<td valign="top" align="center"><font size="5">COLOR</font></td>
<td valign="top" align="center"><font size="5">SIZE</font></td>
<td valign="top" align="center"><font size="5">DESCRIPTION</font></td>
</tr>
<tr>
<td height="70" valign="middle" align="center"><font size="5"><? echo strempty($row['Color']);?></font></td>
<td height="70" valign="middle" align="center"><font size="5"><? echo strempty($row['Size']);?></font></td>
<td height="70" valign="middle" align="center"><font size="5"><? echo strempty($row['Description']);?></font></td>
</tr>
<tr>
<td height="418" valign="middle" align="center" colspan="3">

<span id="huge"><? echo $row['Tag_ID'];?></span><br>
<span id="barcode"><? echo $row['Tag_ID'];?></span><br>
</td>
</tr>
</table><br><Br>
<p style="page-break-after: auto"><?
}
?>
</p>
</body>
</html>
jzint1267
 
Posts: 5
Joined: 21. December 2012 20:49
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Data Not Pulling From Table

Postby hackattack142 » 27. December 2012 18:02

Something looks off with your SQL query.

Are you trying to do
Code: Select all
"SELECT * FROM _equipment_in_stock WHERE Tag_ID BETWEEN '".$_POST['starttag']."' AND '".$_POST['endtag']."' ";

or
Code: Select all
"SELECT Tag_ID, Type, Department, Attention, Category, Customer, Store_Number, Part_Number, Model_Number, Serial_Number, Color, Size, Description FROM _equipment_in_stock WHERE Tag_ID BETWEEN '".$_POST['starttag']."' AND '".$_POST['endtag']."' ";

You should do one or the other
XAMPP Control Panel Developer
Latest CP: viewtopic.php?f=16&t=48932
hackattack142
 
Posts: 703
Joined: 20. May 2011 23:29
XAMPP Version: 5.6.3
Operating System: Windows 7 Ultimate SP1 64-Bit

Re: Data Not Pulling From Table

Postby WilliL » 27. December 2012 18:25

do you get a connect to your database?
Code: Select all
     // @ no error displayed on call
$db_link = @mysql_connect($db_host,$db_user,$db_pass) or die('not connected: '.mysql_error());
     // on error $db_link contains "False"
@mysql_select_db($db_name) or die('database not found: '.mysql_error());
     // $db_link enthält "False" bei einem Fehler, sonst die Verbindungskennung
Willi
WilliL
 
Posts: 623
Joined: 08. January 2010 10:54
XAMPP Version: 5.5.19
Operating System: Win7Home Prem 64 SP1

Re: Data Not Pulling From Table

Postby jzint1267 » 27. December 2012 19:54

I have really not done any coding to check and see if I am connecting to the db. Based on the second scenario from hackattach above, that is the coding that I had but started playing with it this morning and it still did not work. I will put in some coding to check the db connection and see what happens.It is strange that this and another page similar to it for generating delivery tickets is doing the same thing. Except with the movement ticket, the table stucture remains just no information. If I run the tag in Chrome, the table strucure is there but no information.

Here is what I get with the tag output (should be in a three column 9 row table-these are the headers and under them is the information from the db):

TYPE DEPARTMENT ATTENTION CATEGORY CUSTOMER STORE NUMBER PART NUMBER MODEL NUMBER SERIAL NUMBER COLOR SIZE DESCRIPTION

Same similar with the movement ticket but still have the table structure
jzint1267
 
Posts: 5
Joined: 21. December 2012 20:49
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Data Not Pulling From Table

Postby jzint1267 » 27. December 2012 20:19

I am also seeing some of the PHP code when I do a view source from the browser.....is this an indication that the coding is not quoted correctly or because the PHP information is not being handled correctly by the server or both?
jzint1267
 
Posts: 5
Joined: 21. December 2012 20:49
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Data Not Pulling From Table

Postby hackattack142 » 28. December 2012 01:37

Well, I do not code in PHP but if I had to make a guess, I would say you are using short open tags (using <? ?> instead of <?php ?>). I think it is turned off by default in the latest XAMPPs but you can enable it if you like in php.ini
XAMPP Control Panel Developer
Latest CP: viewtopic.php?f=16&t=48932
hackattack142
 
Posts: 703
Joined: 20. May 2011 23:29
XAMPP Version: 5.6.3
Operating System: Windows 7 Ultimate SP1 64-Bit


Return to XAMPP for Windows

Who is online

Users browsing this forum: Altrea, interloperux and 71 guests