Posted by weirdstuff on 03/20/06 03:31
Hi. I have this simple code:
===========================================
->Database query here
(.. some code)
$row=mysql_fetch_array($res);
(...)
$formatting2 = $row['formatting2"];
(..)
//Echo variable from DB
echo "$formatting2";
$formatting2 = "USERNAME: %1\$s \r\nSERIAL: %2\$s \r\n\r\n";
//Echo same string - this time from an "inline" variable
echo "$formatting2";
===========================================
Ok, maybe that was overly complicated. I hope you follow anyway. Whats
happening here is that I am getting a formatted string from a database
which I throw in a variable. What you see here is my test case to
visualize the problem. Now, when I echo this variable or pass it to
printf/sprintf then I get a different result than if I "manually"
create the variable inline in my php script.
So, the first echo $formatting2 there will output:
USERNAME: %1$s \r\nSERIAL: %2$s \r\n\r\n
whilst the second shows the newlines correctly. Also printf/sprintf
barfs if I pass the string I got from the DB.
What the heck is going on here? Database returning some strange string
format?
Thanks :)
Arni Johannesson
Navigation:
[Reply to this message]
|