Solved

Need another set of eyes on accessing variable.

Posted on 2016-07-15
4
22 Views
Last Modified: 2016-07-15
I can't see what's wrong with this (the query is correct and returns 5000+ records).

$SqlString = "select * from comp";
$comp = $conn->query($SqlString);
$row_comp = $comp->fetch_array();
$work = $row_comp['TID'];

$work ends up as "TID"
0
Comment
Question by:breeze351
4 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 41713328
Looks fine from here.  What do you think it is supposed to do?
http://php.net/manual/en/mysqli-result.fetch-array.php
0
 
LVL 21

Accepted Solution

by:
Kim Walker earned 500 total points
ID: 41713337
This would suggest that the value of the column "TID" in the first row of your result is also "TID". Did you upload a CSV file that had a header row? If you did, the first row in your table is that header row.

Other that this, there isn't enough information here to guess. Have you run the query in your database control panel to see what the values are in the first row?
1
 

Author Closing Comment

by:breeze351
ID: 41713357
BINGO!!!!!  Never would have thought of it.
Thanks
0
 
LVL 11

Expert Comment

by:Ovid Burke
ID: 41713366
I tend to agree with Kim. It seems likely that at least one row in tour data contains the column names of your table.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

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

12 Experts available now in Live!

Get 1:1 Help Now