Forum Moderators: coopster

Message Too Old, No Replies

php not working in dreamweaver mx

dreamweaver inputs strange formatting to php files

         

vkimura

11:00 pm on Sep 7, 2003 (gmt 0)

10+ Year Member



I've been having problems with php in dreamweaver mx. I wrote some basic code in dreamweaver mx such as:
<?PHP
$to = "me@mysite.ca";
$msg = "$name\n\n";
$msg .= "$message\n\n";
$subject= "PHP FormMail Results";
mail($to, $subject, $msg, "From: $email");
echo "Data sent! ;)";
echo "<meta http-equiv='Refresh' content='1;
URL=http://www.myothersite.com/index.html'>";
?>

It didn't work. Then I rewrote this exact piece using a basic text editor (i.e. Notepad), uploaded it and it worked. Is there some setting in dreamweaver mx that inputs strange formatting into the code. I know programs like MSWord does this but I don't the work around to this. Any help would be appreciated.

[edited by: jatar_k at 12:16 am (utc) on Sep. 8, 2003]
[edit reason] generalized url and email [/edit]

jatar_k

12:20 am on Sep 8, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld vkimura,

always good to see another canadian. ;)

A developer I work with uses mx to do a little bit of php, though I try to discourage it, and I have never had a problem getting it to run. Whem we use non php extensions he sometimes gives me files with an extension that is not parsed by our servers (htm) but aside from that I am not aware of any problems.

Try to analyze all the steps you took, maybe it was some other part of the procedure that was the problem. Sorry I can't give more insight.

knighty

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

WebmasterWorld Senior Member 10+ Year Member



I use MX all the time to develop PHP and have noticed this on a couple of occaisions although I havent noticed it recently - seems to be a problem with header type stuff like cookies etc.

I've been creating php pages as HTML rather than using the suggested PHP (the options that MX gives you when you select "New")

jatar - the default extension is htm but you can change it to whatever you want.

jamie

2:36 pm on Sep 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



sorry to hijack the thread vkimura ;-), but knighty..

if you create php pages as html in DW don't you lose all your colour syntax highlighting? at the moment i save everything as php and then change the extension on upload.

cheers

X_Factor

4:00 pm on Sep 8, 2003 (gmt 0)



I create PHP pages in Dreamweaver MX all the time. I never had a problem with it.

timster

6:45 pm on Sep 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



vkimura

Are you maybe having trouble with line endings? That can break PHP code fast, while the HTML & CSS still work.

Make sure Dreamweaver is set to use whatever line endings (e.g., CRLF, LF) that your Web server expects.

henry0

7:07 pm on Sep 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I do not use DW
although I reviewed a temp d-load about one year ago
I might be wrong
but if I remember correctly ...
DW had some add ons to futher PHP and its syntax?
did you look all over DW for PHP support?
henry

knighty

7:58 am on Sep 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>if you create php pages as html in DW don't you lose all your colour syntax highlighting?

No, I open a HTML file and then save as PHP - I did used to get problems creating them in as PHP but not with HTML - dont know why... :/

bpositive

9:22 pm on Sep 9, 2003 (gmt 0)

10+ Year Member



Hi,
Don't you need to escape that ';' in the last echo, just before the 'URL'?

Be Positive

willybfriendly

10:15 pm on Sep 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



echo "<meta http-equiv='Refresh' content='1;
URL=http://www.myothersite.com/index.html'>";

echo "<meta http-equiv='Refresh' content='1' URL=http://www.myothersite.com/index.html'>";

might work better. Not the closing single quote on content='1' and removal of the semi.

So, hard to say if it is dreamweaver or this snippet. Getting any run time errors?

WBF

vkimura

2:47 am on Sep 10, 2003 (gmt 0)

10+ Year Member



timster

Are you maybe having trouble with line endings? That can break PHP code fast, while the HTML & CSS still work.

Make sure Dreamweaver is set to use whatever line endings (e.g., CRLF, LF) that your Web server expects.

I apologize for my ignorance. But what are CRLF and LF's?

vkimura

PS-I have some code working now. I don't know what wrong with some of the php code but when I rewrote it in Notepad then it worked. I don't have any problems currently. Very strange. If I come up with a specific problem I'll be sure to post it. Thanks for all the feedback!

timster

4:22 pm on Sep 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



vkimura,

No apology is necessary -- I should have been more clear. But yes, you should learn about line endings, or they'll bite you:

LF "Line Feed" is the (typical) line ending for Unix (including Mac OS X)
CRLF "Carriage Return, Line Feed" is the line ending for Windows
CR "Carriage Return" is the line ending for MacOS 9 and previous.

Linefeed is ASCII character 10
Carriage Return is ASCII character 13

Most text editor (I think DreamWeaver included) can save files with any of these line endings in case you plan to upload it to a server of that platform.

If your document is saved with Unix line endings, Windows will consider (basically) as one long line. That won't usually break HTML, but it will break PHP, as well as most other code.

But when you look at it in your editor, it may look exactly like the code that works.