$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:

Recommended Answers

It is a lot more difficult in C language see ODBC tutorials

Jump to Post

All 2 Replies

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:


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.