$content_array = explode($file_contents);
//Remove duplicate entries
$flipped_array = array_flip($content_array);
file_put_contents('/path/to/file', implode("\n", array_keys($flipped_array));
我想在名为userdetails的表中输入详细信息。它给了我一个输出,使得连接没有被建立。请通过它并帮助我。我正在使用codeblock ide和mySql5.1
答案 0 :(得分:0)
尝试如下:
MYSQL mysql,*connection;
MYSQL_RES result;
MYSQL_ROW row;
mysql_init(&mysql);
connection =mysql_real_connect(&mysql,"localhost","root","12356","hari",0,NULL,0);
if (connection==NULL)
{
cout<<mysql_error(&mysql)<<endl;
}
else{
nQueryState = mysql_query(&mysql,"insert into userdetails values('"+nId+"','"+szName+"','"+szPassword+"','"+szQuestion+"','"+szPhone+"')");
if (nQueryState !=0) {
cout << mysql_error(connection) << endl;
return 1;
}
}
mysql_close(&mysql);
参见:http://www.codeproject.com/Questions/337901/How-to-insert-data-in-database-using-Cplusplus