<?php
$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)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";

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

mysql_close($con)
?>

This is my code in php..i want it in C..any help? what should be written instead of:
'$_POST[firstname]','$_POST[lastname]','$_POST[age]'

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:

http://dev.mysql.com/doc/refman/5.0/en/c-api-function-overview.html

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.