Page 1 of 1

I can't see why this is wrong

Posted: Wed Jun 14, 2006 1:45 pm
by akimm
Well for now I'm going to post the code that I am having an error with, the one you suggested to format the textfile
This is the error is prints:

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /nfs/cust/8/25/05/650528/web/clairictionary/clairictionary.php on line 590

Code: Select all

<?php
// write the info using the format needed so I don't have to edit it!
// id the variable to show how I want the $entry to look!

$entry = $name . #datasep# . $word . #datasep# . $definition . 

#entrysep;

$write_string = $entry
fwrite($fp, $write_string);

fclose($fp)

?>
If I'm not clear, my basic objective is to simply write to a file via a form ((already wrote it) this is just the error proned part of the code) and format the entrys to look like this

$name#datasep#$word#datasep#definition#entrysep#

Posted: Wed Jun 14, 2006 1:52 pm
by bdlang
You are trying to concatenate a string literal without quoting it, and the hash marks '#' have created comments in your code.

Code: Select all

<?php

// ASSUMES YOU CREATE A FILEPOINTER HERE WITH fopen()

// write the info using the format needed so I don't have to edit it!
// id the variable to show how I want the $entry to look!

$entry = $name . '#datasep#' . $word .' #datasep#' . $definition . '#entrysep';

fwrite($fp, $entry);

fclose($fp)

?>

ah yes

Posted: Wed Jun 14, 2006 1:54 pm
by akimm
well double quotes jacked it up, so i tried no quotes at all, lol, thanks for clearing up a green hornes stupidity.

Re: ah yes

Posted: Wed Jun 14, 2006 1:59 pm
by bdlang
akimm wrote:well double quotes jacked it up, so i tried no quotes at all, lol, thanks for clearing up a green hornes stupidity.
Hmm, double quotes should have worked just fine, as long as you used this method to seperate the variable name from the #other stuff#, e.g.

Code: Select all

$entry = "{$name}#datasep#{$word}#datasep#{$definition}#entrysep";
PHP Manual: Strings

Scroll down and have a look at the section marked 'Variable parsing'.