Hi,

Don't you mean

strcpy(reseller_prompts, row[0]);
not
strcpy(row[0], reseller_prompts);

Quentin

-----Original Message-----
From: Matthew Blacklow [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 14 November 2001 1:30 p.m.
To: [EMAIL PROTECTED]
Subject: Storing returned string into variable in C


I am having trouble storing the result of a query into a variable when the
query returns a string.
Using phpmyadmin I test the query and it definitely works. So knowing that
the problem does not lie in the query.
My code contains several other queries all of which work, the only
difference is that they obtain their data from integer fields instead of
varchar fields. This is what it stores into the string "(Ø". This is because
it seems that this is the value returned by the query as when i print row[0]
that is what it prints.

Included below is the problem code:

sprintf(query_string, "SELECT this FROM that WHERE something = %d",
var_something);
if (debug) printf("%s\n", query_string);

if (mysql_query(&mysql, query_string)){
        if (debug) printf("ERROR");
          return 1;
}

result = mysql_store_result(&mysql);

if (mysql_num_rows(result) == 0){
        printf("Error Occured\n");
        return 1;
}

row = mysql_fetch_row(result);

/*here is where I attempt to copy the string returned from the query into
the variable, some of the code below is only there for debugging purposes*/

strcpy(row[0], reseller_prompts);
printf("--%s--\n", row[0]);
printf("--%s--\n", reseller_prompts);
mysql_free_result(result);

All help appreciated,
Matthew


---------------------------------------------------------------------
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
The information contained in this email is privileged and confidential
and intended for the addressee only. If you are not the intended 
recipient, you are asked to respect that confidentiality and not 
disclose, copy or make use of its contents. If received in error 
you are asked to destroy this email and contact the sender immediately. 
Your assistance is appreciated.

---------------------------------------------------------------------
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

Reply via email to