Solved

PHP & MSSQL - certain fields not being displayed?

Posted on 2011-02-25
4
286 Views
Last Modified: 2013-12-13
Hi all

I'm having a problem displaying certain fields from an sql query with php - if i run the same code in management studio i get the output without any problems - the section of code in question:

$query1="SELECT Job, StockCode, StockDescription, Qty FROM =AssyJobs";
$jobsquery = mssql_query("query1");

while(($q1 = mssql_fetch_array($jobsquery)) !== false)
  {
      $Job      = $q1['Job'];
      $StockCode       = $q1['StockCode'];
      $Description      = $q1['StockDescription'];
      $Qty      = $ql['Qty'];

      echo $Job;
      echo $StockCode;
      echo $Description;
      echo $Qty;

when i run the above, i get the Job, Stock Code & Description being displayed, but no qty?

If i run the code in Management Studio, i get a value in all fields/columns?

Anyone know where ive gone wrong?

Thanks :)
0
Comment
Question by:Bergstr
  • 3
4 Comments
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 34978260
Is the column in the MSSQL qty or Qty? PHP variable names are case sensitive as are array indexes.
0
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 500 total points
ID: 34978263
On closer inspection, your result set is q1 and the qty row is ql

Change "Q ELL" to "Q ONE"
0
 

Author Comment

by:Bergstr
ID: 34978297
Thats the problem! working perfectly now.

I just had a look in dreamweaver where im writing the code, and 1's and l's in their lower case form are, as far as i can tell, identical... which doesnt really help with problems like this..!

 Thanks for the help :)
0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 34978342
I had a similar problem. The textarea font is rather small on my display but when I cut'n'pasted it into a editor......

Glad you're sorted.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question