Forum Moderators: coopster

Message Too Old, No Replies

How to allow a quotation in a variable

Will this work

         

mack

5:27 am on Sep 8, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I am pretty much a beginer in terms of php. I am currently writting a simple script to allow a user to create a small section of a page by filling out forms. Part of the script contains ready made html to be included.

I need to have something like this...
$thing="the variable but" with quotes" in the middle";

Would this work...
$thing="the variable but\" with quotes\" in the middle";

Thanks in advance.

Mack.

Nick_W

6:42 am on Sep 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you try it Mack? ;)

Yeah, it works....

Nick

mack

7:00 am on Sep 8, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Yep tried it, but with all my other errors I wasn't sure if I had got it right ;)

Here is the code that is causing the problems

$data = "data.txt";
$Open = fopen ($data, "a");
if ($Open) {
fwrite ($open,
"$1st,$2nd,$3rd,$4th,$5th,$6th \n");
fclose (sopen);
$worked = "true";
} else {
$worked = "false";
}

All the variables are passed from a form but I get...
Warning: fwrite(): supplied argument is not a valid File-Handle resource in activate.php on line 10

Any ideas :)

Mack.

Nick_W

7:02 am on Sep 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$data needs to be an exact path like /usr/www/etc/data.txt or a relative path to where the script is being run like ../data.txt

Also, on the fclose you need to close $Open.

Try that...

Nick

vincevincevince

8:28 am on Sep 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



variables are case sensitive - make them all $open not $Open or any other variants.... and you _should_ be able to specify $data in the way you have

mack

8:30 am on Sep 8, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Changed but still giving same error. :(

<?php
$data = "/web/sites/354/clickfor/www.domain.com/dir/date.txt";
$Open = fopen ($data , "a");
if ($Open) {
fwrite ($open,
"$1st,$2nd,$2rd,$4th,$5th,$6th \n");
fclose ($open);
?>

Any more ideas?

Mack.

Nick_W

8:32 am on Sep 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$open and $Open are not the same variable.

Nick

mack

8:41 am on Sep 8, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



WOW thanks guys, Don't belive I never spotted that.

Thanks loads.

Mack.