• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 46
  • Last Modified:

Need another set of eyes on accessing variable.

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
breeze351
Asked:
breeze351
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
Looks fine from here.  What do you think it is supposed to do?
http://php.net/manual/en/mysqli-result.fetch-array.php
0
 
Kim WalkerWeb Programmer/TechnicianCommented:
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
 
breeze351Author Commented:
BINGO!!!!!  Never would have thought of it.
Thanks
0
 
Ovid BurkeCreative DirectorCommented:
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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now