Reply to String variable read from Mysql DB + echo = Newline problem

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация