} else {
res_ptr = mysql_use_result(&my_connection);
if (res_ptr) {
if ((mysqlrow = mysql_fetch_row(res_ptr))) {
sscanf(mysqlrow[0], "%d", &artist_id);
}
mysql_free_result(res_ptr);
}
}
return artist_id;
} /* get_artist_id */
Переходите к вставке информации о дорожках для вашего компакт-диска. И снова защититесь от специальных символов в названиях дорожек:
int add_tracks(struct current_tracks_st *tracks) {
int res;
char is[250];
char es[250];
int i;
if (!dbconnected) return 0;
i = 0;
while (tracks->track[i][0]) {
mysql_escape_string(es, tracks->track[i], strlen(tracks->track[i]));
sprintf(is,
"INSERT INTO track(cd_id, track_id, title) VALUES(%d, %d, '%s')",
tracks->cd_id, i + 1, es);
res = mysql_query(&my_connection, is);
if (res) {
fprintf(stderr, "Insert error %d: %s\n",
mysql_errno(&my_connection), mysql_error(&my_connection));
return 0;
}