# PHP/MySQL - Can you echo an int?



## Akumos (Apr 30, 2012)

Hi

playerid and level are both integers... This is my code:


```
echo "<center><BR>Results: ".$dbRecord["playerid"].", Level: ".$dbRecord["level"]."</center>";
```

And this is my result:

Results: , Level:  (no data)

Can you echo an Int or do I need to parse it? Is there an easy way?

Thanks


----------



## Akumos (Apr 30, 2012)

No worries - I'm halfway there!


----------



## Disparia (Apr 30, 2012)

No, your code looks sound. PHP's automatic type casting handles str/int concatenation without additional logic. Also, if you're getting a record from the database as your variable name implies, it's probably all being treated as a string anyway. Only need to cast to an int when you want to ensure it's being treated as such (Ex: bitwise comparisons, it's very important here).

It may just be an empty array and the problem is before your echo, or there is no problem - it's just an empty record in your database or your query didn't return any data.

Can do a print_r( $dbRecord ) or var_dump( $dbRecord ) to display everything that array contains. Post more of your script if you need further assistance.


----------



## Akumos (Apr 30, 2012)

Thanks Jizzler - that helps alot... 

I'm acutally selecting from different tables... this is what your suggestion produced, which suuggests the data is there but not displaying!

code:

```
echo "<center><BR>Results are: ".$dbRecord[players.playerid].", Level: ".$dbRecord[players.level]."</center>";
		print_r( $dbRecord );
```

Results are: , Level: 
Array ( [0] => 20 [id] => 20 [1] => 22960 [playerID] => 22960 [2] => 10 [galexy] => 10 [3] => 10 [region] => 10 [4] => 10 [system] => 10 [5] => 10 [astro] => 10 [6] => 0 [cc] => 0 [7] => 10 [bk] => 10 [8] => 0 [lt] => 0 [9] => [mt] => [10] => [pst] => [11] => [it] => [12] => [pht] => [13] => [dt] => [14] => [ds] => [15] => [ps] => [16] => [pr] => [17] => [fleet] => [18] => 2012-04-30 [date] => 2012-04-30 [19] => 22960 [playerid] => 22960 [20] => 30.73 [level] => 30.73 )


----------



## Akumos (Apr 30, 2012)

ok i took out the table name and it works 

thanks jizz


----------

