just add
mysql_init(&csql);
before accessing the struct for any purpose.
Sure it helps (I made the same mistake, got the same result ;-)
Uwe
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, September 01, 2001 8:25 PM
Subject: Mysql C API Problem
> am connecting to a mysql server on localhost i put all the code in a
function call mysql_conlocal
> MYSQL csql;
> int mysql_conlocal() {
> puts("Connecting to Mysql Server");
> if(!mysql_connect(&csql,DBHOST,DBUSER,DBPASS)) {
> puts("Failure!");
> puts("This Could Because");
> puts("A Your Username or Password is incorrect");
> puts("B Your Server is not running or is down");
> puts("C Your login name does not have access to connect from this machine
");
> exit(1);
> }else if (mysql_select_db(&csql,DB) !=0) {
> puts("Connecting to DB....Failure!");
> puts("This is probably because the DB Doesnt exist or you username doenst
have access to it");
> exit(1);
> }
> puts("Connecting to DB... Success!");
> }
>
> but it generates a segmentation fault
>
> but if i take i out of my own application and run it as a seperate app it
runs fine
> i am also using another socket in my application to connect to another
server medium
> it is called sockfd
> could this cause problems
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php