Solved

PHP & MSSQL - certain fields not being displayed?

Posted on 2011-02-25
4
275 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now