Page 1 of 1
Resource id #7 problem in mysql
Posted: Wed Mar 17, 2010 4:43 am
by majidali
hello every ,can any explain what is "Resource id #7" means
i have fired a query-
$query="select * from custdetail order by createdON desc limit $offset,$record_per_page ";
$data=mysql_query($query);
echo $data;
this echo prints Resource id #7 wat does this means how is it useful.......
Re: Resource id #7 problem in mysql
Posted: Wed Mar 17, 2010 4:55 am
by Turv
majidali wrote:hello every ,can any explain what is "Resource id #7" means
i have fired a query-
$query="select * from custdetail order by createdON desc limit $offset,$record_per_page ";
$data=mysql_query($query);
echo $data;
this echo prints Resource id #7 wat does this means how is it useful.......
That's because $data is literally just the Resource ID from the Query - You have to get it into a usable array first before you can use it. I.e,
Code: Select all
$query="select * from custdetail order by createdON desc limit $offset,$record_per_page ";
$data=mysql_query($query);
while($row = mysql_fetch_array( $data)) {
echo $row['field_name'];
}
Re: Resource id #7 problem in mysql
Posted: Wed Mar 17, 2010 4:57 am
by majidali
Turv wrote:majidali wrote:hello every ,can any explain what is "Resource id #7" means
i have fired a query-
$query="select * from custdetail order by createdON desc limit $offset,$record_per_page ";
$data=mysql_query($query);
echo $data;
this echo prints Resource id #7 wat does this means how is it useful.......
That's because $data is literally just the Resource ID from the Query - You have to get it into a usable array first before you can use it. I.e,
Code: Select all
$query="select * from custdetail order by createdON desc limit $offset,$record_per_page ";
$data=mysql_query($query);
while($row = mysql_fetch_array( $data)) {
echo $row['field_name'];
}
thanx for that but i want to know wat does Resource id #7 ......
Re: Resource id #7 problem in mysql
Posted: Wed Mar 17, 2010 5:01 am
by Turv
majidali wrote:Turv wrote:majidali wrote:hello every ,can any explain what is "Resource id #7" means
i have fired a query-
$query="select * from custdetail order by createdON desc limit $offset,$record_per_page ";
$data=mysql_query($query);
echo $data;
this echo prints Resource id #7 wat does this means how is it useful.......
That's because $data is literally just the Resource ID from the Query - You have to get it into a usable array first before you can use it. I.e,
Code: Select all
$query="select * from custdetail order by createdON desc limit $offset,$record_per_page ";
$data=mysql_query($query);
while($row = mysql_fetch_array( $data)) {
echo $row['field_name'];
}
thanx for that but i want to know wat does Resource id #7 ......
When you perform a query, mysql_query() returns the Resource ID for that Query, NOT the raw data from the database. You then use that resource id ($data) to extract the data from that Query.