CODE
{
mysql_connect('localhost','username','password');
mysql_select_db('some database');
$res=mysql_query("select dept_name from dept where deptid=1);
echo $res;
}
i tried to print value of res variable but it is showing output as "RESOURCE ID #4" or some value followed by resource id
but "i think the value shud be the value returned by mysql_connect function'
i donno why actual value of $res is not shown
so kinldly work on this and let me know how to print the actual value of $res
my code is not working plzz help me out
Moderator: General Moderators
-
hari_reddyc
- Forum Newbie
- Posts: 1
- Joined: Wed Jul 09, 2008 11:29 pm
Re: my code is not working plzz help me out
hari to display the value you have to use mysql_result($res,0);
or use mysql_fetch_array,mysql_fetch_assoc,mysql_fetch_row
you will get your required results
thanks and regards
pari
or use mysql_fetch_array,mysql_fetch_assoc,mysql_fetch_row
you will get your required results
thanks and regards
pari
Re: my code is not working plzz help me out
[quote="hari_reddyc"]
The result of mysql_query() is just a pointer to a "resource", meaning that it is a potentially huge array of data, so you can't just echo or print it. You have to use other mysql functions to recover the data, as the previous responder explained.
Code: Select all
$res=mysql_query("select dept_name from dept where deptid=1);
echo $res;