Solved

PHP & MSSQL - certain fields not being displayed?

Posted on 2011-02-25
4
285 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

808 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