Page 1 of 1

my code is not working plzz help me out

Posted: Wed Jul 09, 2008 11:42 pm
by hari_reddyc
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

Re: my code is not working plzz help me out

Posted: Thu Jul 10, 2008 12:32 am
by parimala
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

Re: my code is not working plzz help me out

Posted: Thu Jul 10, 2008 12:50 pm
by califdon
[quote="hari_reddyc"]

Code: Select all

 
$res=mysql_query("select dept_name from dept where deptid=1);
echo $res;
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.