hi all,
i need to echo the value obtained in the mysql query. so can any one ..
Thank u..

$sql2="select reportingto from users where username='$_SESSION[username]'";
   mysql_error();
   $result2 = mysql_query($sql2);
echo $result2;
Member Avatar for rajarajan2017

Just want to echo, or not getting the result from the sql query.

echo $result2;

as almostbob suggested
or use

print $result2;

Just want to echo, or not getting the result from the sql query.

echo $result2;

as almostbob suggested
or use

print $result2;

i got it as 'Resource id #4'
i think we need to use some thing like 'mysql_fetch_array'

Member Avatar for rajarajan2017

Point out clearly nith, ok let take a look at below and change over to your code

$query = "SELECT * FROM symbols"; 
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
if (mysql_num_rows($result) > 0) { 
while($row = mysql_fetch_row($result)) { 
echo $row[0];
}
}

This will output your first field in your databse, use $row[1],$row[2] etc.

Point out clearly nith, ok let take a look at below and change over to your code

$query = "SELECT * FROM symbols"; 
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
if (mysql_num_rows($result) > 0) { 
while($row = mysql_fetch_row($result)) { 
echo $row[0];
}
}

This will output your first field in your databse, use $row[1],$row[2] etc.

ha ha i got it... thank u. and that sorry for my poor english...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.