Solved

PHP & MSSQL - certain fields not being displayed?

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

809 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