Error Checking

Hey guys i am facing a problem in my sql statement. I am trying to check if there is such a value in the database.

 Code:
       
      string NewMovie = "ww";
  
      string queryText ;
  
   

  queryText = "Select * from movie_info WHERE movie_title = '"+ NewTitle +"'";
      MYSQL *conn;

      conn=mysql_init(NULL);
 
     mysql_real_connect(conn,host,username,password,database,0,NULL,0);
  

  mysql_query(conn,queryText.c_str());
  
       ????
 
      mysql_close(conn);
  
       

      return 0; 

The problem i am facing is how do i check if the value is found. I read up and found that a query will return a value of TRUE if the query is a success and a FAIL if there is an error. How do i call these values and then based the check on it?

How do you call those values? I don't understand the question. mysql_query returns those values.

if(mysql_query(...) == 0)
{
  // stuff to do if query was successful
}

"query successful" doesn't mean it found it, either -- it means the query didn't have an error.

According to the manual you're supposed to check if there is a result set by calling mysql_field_count. If it gives you a positive number of columns, you can go ahead and fetch data with mysql_store_result.

if(mysql_query(...) == 0)
if(mysql_field_count(...) > 0)
{ // Get the results, if any
  MYSQL_RES *result=mysql_store_result(...);

  // Stuff to do with results
}