Resource id #7 problem in mysql

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
majidali
Forum Newbie
Posts: 17
Joined: Thu Mar 11, 2010 3:33 am

Resource id #7 problem in mysql

Post 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.......
Turv
Forum Commoner
Posts: 25
Joined: Fri Mar 13, 2009 3:56 pm

Re: Resource id #7 problem in mysql

Post 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'];
}
 
 
majidali
Forum Newbie
Posts: 17
Joined: Thu Mar 11, 2010 3:33 am

Re: Resource id #7 problem in mysql

Post 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 ......
Turv
Forum Commoner
Posts: 25
Joined: Fri Mar 13, 2009 3:56 pm

Re: Resource id #7 problem in mysql

Post 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.
Post Reply