Solved

PHP & MSSQL - certain fields not being displayed?

Posted on 2011-02-25
4
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
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…

734 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