FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


What's wrong with this line?





DSGamer3002
Code:
fwrite($fp, "<tr>\n<td class=/"entrant_list/">\n".$wifin."</td>\n</tr>\n");


I haven't used PHP in over a year, so give me a break if I made some really stupid error. Smile I get an error saying "Parse error: syntax error, unexpected T_STRING". I think that has something to do with the \n things mixing with the html I'm trying to write, but I don't know how to fix it. Can someone help me out?

Thanks.
simplyw00x
You want
Code:
fwrite($fp, "<tr>\n<td class=\"entrant_list\">\n$wifin</td>\n</tr>\n");
or
Code:
fwrite($fp, '<tr>\n<td class="entrant_lis\">\n'.$wifin.'</td>\n</tr>\n');


Escapes are \, not / - but if you're using string concatenation ("foo"."bar") instead of variable substitution you can use single-quotes around the whole thing instead.
DSGamer3002
simplyw00x wrote:
You want
Code:
fwrite($fp, "<tr>\n<td class=\"entrant_list\">\n$wifin</td>\n</tr>\n");
or
Code:
fwrite($fp, '<tr>\n<td class="entrant_lis\">\n'.$wifin.'</td>\n</tr>\n');


Escapes are \, not / - but if you're using string concatenation ("foo"."bar") instead of variable substitution you can use single-quotes around the whole thing instead.


Well, I think I got what you're saying, so I tried this:

fwrite($fp, '<tr>\n<td class="entrant_list">\n'.$fc.'</td>\n</tr>\n');

But when I did that, it wrote the actual text "\n" to the file I'm writing to. \n is supposed to signify a new line I thought?
mathiaus
Use simplyw00x's first example. \n and \r nned to be in double quotes from what I remember.
simplyw00x
Quote:
Use simplyw00x's first example. \n and \r nned to be in double quotes from what I remember.

Congratulations me for forgetting that \n *is* an escaped sequence. Hur hur.
manav
replace \n by \\n i guess
snowboardalliance
manav wrote:
replace \n by \\n i guess


No, just use double quotes. "\\n" would print "\n" if you actually wanted that.
Manofgames
Just for clarification,
Code:

''

Creates / echo's a string literally i.e., you type
Code:

$somevar = 'google';
echo '$somevar';

and it will echo
Code:

$somevar

Because it takes $somevar literally as a dollar sign and some text.

Wheras with
Code:

$somevar = 'google';
echo "$somevar";

It will echo
Code:
google
Because PHP parses the string, and replaces $somevar with its content (google)

Hope this helps a little bit Smile
Related topics
Header image change? How to!!
wrong configuration or server software (settings)? solved
What if your beliefs are wrong?
Technical problem... help with this line of code?
I'm doing something wrong,,,
Premarital Sex?
unserialise ??? can somebody explain what's wrong to me
Something wrong with Fantastico Cpanel Skin Many Problems
what is wrong with this query? Please please help!
The Universe Big Bang is wrong
all a waste of space???
Are boys always wrong?
What is wrong? HELP!
Professional/Personal Line at Work
Huck Finn
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.