hi forum
i was working with odbc and used odbc_exec(). but when i used this in mysql this is not working i also used mysql_query() but this is not working too
here is the code

$id;
$sr;
$cs='fa';
$q2="SELECT MAX(ser) AS mxid FROM (SELECT * FROM Table1 AS T2 where subject='".$cs. "')";
if(!($result = mysql_query($q2))){
echo "whoooooooooooooooooooooops";
}// or die();
else{
while(mysql_fetch_row($result)){
$sr=mysql_result($result, "mxid");
echo "MAX IS ".$sr; 
}

you need to connect and select a DB with the above method

$conn = mysql_connect("localhost","username","password");
      mysql_select_db("database",$conn);

$conn = mysql_connect("localhost","username","password"); mysql_select_db("database",$conn); i have used that but problem is in query

what is "not working" then. please supply error codes.

There is no error message but whoooooooooooooooops

there is an error message. You are ignoring it.


The problem is your SQL

$q2="SELECT MAX(ser) AS mxid FROM (SELECT * FROM Table1 where subject='".$cs. "')  AS T2";

this is your solution

Oh thanxxx its working

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.