Re: mysql_init(&m) deleting Variable values
Ok well, I figured it out. the key was null pointers. I changed my code to this:
MYSQL_RES *result;
MYSQL_ROW row;
MYSQL *connection, *mysql;
int state;
if(CFArrayGetCount(params) < 7) return CFSTRRetain("false\rArrr, pirate! Too few params!"); //5 is the num of params expected.
CFStringRef dbServer = CFArrayGetValueAtIndex(params,0);
CFStringRef dbUser = CFArrayGetValueAtIndex(params,1);
CFStringRef dbUserPass = CFArrayGetValueAtIndex(params,2);
CFStringRef dbName = CFArrayGetValueAtIndex(params,3);
CFStringRef SQLStatement = CFArrayGetValueAtIndex(params,4);
int queryLen = CFStrLen(SQLStatement);
CFMutableStringRef theData = CFStringCreateMutable(NULL,0);
char *cStrdbServer,*cStrdbUser,*cStrdbUserPass,*cStrdbName,*cStrSQLStatement;
cStrdbServer=ExportToC(dbServer);
cStrdbUser=ExportToC(dbUser);
cStrdbUserPass=ExportToC(dbUserPass);
cStrdbName=ExportToC(dbName);
cStrSQLStatement=ExportToC(SQLStatement);
mysql=mysql_init(NULL);
// and replace any use of &mysql with mysql
connection = mysql_real_connect(mysql,cStrdbServer,cStrdbUser,cStrdbUserPass,cStrdbName,0,NULL,0);
I hope this helps others!