John Millaway wrote:
>
> I'm using PHP to transfer data from my NT mysql db to a linux mysql db.
> (Is there a better way?)
> Sometimes when I select a char field, the first or last character gets
> altered! I'm going nuts over this and I'm pretty sure the error is not
> in the PHP drivers because I've seen it happen in the 'mysql' program.
> The php code and the output is below. Notice the value for the last_name
> field. This happens with every row. Anyone know what's going on?
>
> // PHP CODE SNIPPET
> $query = "select id, RTRIM(first_name), RTRIM(last_name), status_id,
> time, RTRIM(returntime), RTRIM(comment), persistent from person order by
> id";
> $res = mysql_query($query);
> while(($row = mysql_fetch_row($res))){
> echo( "insert into person
> (first_name,last_name,status_id,time,returntime,comment,persistent)
> \n");
> echo( "values (\n");
> echo( "'$row[1]',\n");
> echo( "'$row[2]',\n");
> echo( "$row[3],\n");
> echo( "'$row[4]',\n");
> echo( "'$row[5]',\n");
> echo( "'$row[6]',\n");
> echo( "$row[7]);\n\n");
> break;
> }
>
> AND HERE IS THE OUTPUT:
> bash-2.02$ /php3/php.exe gensql.php3
> Content-type: text/html
>
> insert into person
> (first_name,last_name,status_id,time,returntime,comment,persistent)
> values (
> 'Haresh',
> ',ssumal
> 1,
> '1999-08-18 09:30:00',
> '-',
> '',
> 0);
>
> -John
Hi John
Looks to me, as if there where 0x00 characters in your $row[2] after ',ssumal
Just convert them to \0 before using them!
Tschau
Christian
PS: Sorry for the late answer, I was really busy.