// This is the best way to perform an SQL query
// For more examples, see cubrid_real_escape_string()$query=sprintf("SELECT firstname, lastname, address, age FROM friends WHERE firstname='%s' AND lastname='%s'",cubrid_real_escape_string($firstname),cubrid_real_escape_string($lastname));// Perform Query$result=cubrid_query($query);// Check result
// This shows the actual query sent to CUBRID, and the error. Useful for debugging.if (!$result) {$message='Invalid query: '.cubrid_error() ."\n";$message.='Whole query: '.$query;
die($message);
}// Use result
// Attempting to print $result won't allow access to information in the resource
// One of the cubrid result functions must be used
// See also cubrid_result(), cubrid_fetch_array(), cubrid_fetch_row(), etc.while ($row=cubrid_fetch_assoc($result)) {
echo$row['firstname'];
echo$row['lastname'];
echo$row['address'];
echo$row['age'];
}// Free the resources associated with the result set
// This is done automatically at the end of the scriptcubrid_free_result($result);?>