I have a database with 2 columns, one of type int and other of type varchar.
When i try to get tha name with id=1 for example, the query works fine:
$name = mysql_query("SELECT Name FROM stations_id WHERE id=1");
$a = mysql_fetch_array($name);
echo $a['Name'];
I try to do the opposite but i cant get the integer value. For example:
$id = mysql_query("SELECT id FROM stations_id WHERE Name='Mike'");
$a = mysql_fetch_array($id);
echo $a['id'];
I want to get the type as an integer so i can use it in a function. Can somebody help me plz?
+or/operators and such) it will work. Why do you care about it? (also why wont just cast it with(int)?)echo $a['id'], then no record exists with aNameof'Mike'. On a development server, you should also increase yourerror_reportingand turn ondisplay_errors. That would have warned you about an "Undefined index 'id' ...".