Re: mysql_init(&m) deleting Variable values
Posted by: Bruce Martin
Date: November 13, 2005 09:18AM

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!

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: mysql_init(&m) deleting Variable values
602
November 13, 2005 09:18AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.