$con = mysql_connect("localhost","peter","abc123");
if (!$con)
die('Could not connect: ' . mysql_error());

mysql_select_db("my_db", $con);

$sql="INSERT INTO Persons (FirstName, LastName, Age)

if (!mysql_query($sql,$con))
die('Error: ' . mysql_error());
echo "1 record added";


This is my code in php..i want it in C..any help? what should be written instead of:

With all due respect Ancient Dragon, the best solution to his problem is not ODBC.

ODBC adds additional layers of overhead and configuration complexity to the more obvious solution of linking to the MySQL C library which exposes nearly all the same commands he used in his PHP code.

Here is a link to the MySQL C API reference: