Forums

PHP

This topic is locked

Broken code in UD/MAC

Posted 26 Jan 2002 05:34:25
1
has voted
26 Jan 2002 05:34:25 darko antic posted:
This has been asked before, here and on some other lists, but i couldn't find the answer so here it is again. When using insert record or edit record server behaviour, the saved page opens with "scrambled" code in design view (see image)

<img src="redhusky.com/code.gif" border=0>

the 'weird' code is always the same regardless of the form and cannot be selected, moved or deleted, unless i remove the behaviour from the page.
any ideas?
phakt is 1.1.3, os is mac 9.2, ud4
thanks
darko

the following is the generated code that causes the above:
&lt;?php


// Copyright (c) Interakt Online 2001
// www.interakt.ro/

require("./../adodb/adodb.inc.php";
require("./../Connections/myJTI.php";
?&gt;&lt;?php
// *** Edit Operations: declare Tables
$MM_editAction = $PHP_SELF;
if ($QUERY_STRING) {
$MM_editAction = $MM_editAction . "?" . $QUERY_STRING;
}

$MM_abortEdit = 0;
$MM_editQuery = "";
?&gt;&lt;?php
// *** Insert Record: set Variables

if (isset($MM_insert)){

// $MM_editConnection = MM_myJTI_STRING;
$MM_editTable = "DEPARTMENT";
$MM_editRedirectUrl = "";
$MM_fieldsStr = "DEPTID|value|DEPTNAME|value";
$MM_columnsStr = "DEPTID|none,none,NULL|DEPTNAME|',none,''";

// create the $MM_fields and $MM_columns arrays
$MM_fields = explode("|", $MM_fieldsStr);
$MM_columns = explode("|", $MM_columnsStr);

// set the form values
for ($i=0; $i+1 &lt; sizeof($MM_fields); ($i=$i+2)) {
$MM_fields[$i+1] = $$MM_fields[$i];
}

// append the query string to the redirect URL
if ($MM_editRedirectUrl && $QUERY_STRING && (strlen($QUERY_STRING) &gt; 0)) {
$MM_editRedirectUrl .= ((strpos($MM_editRedirectUrl, '?') == false)?"?":"&" . $QUERY_STRING;
}
}
?&gt;&lt;?php
// *** Insert Record: construct a sql insert statement and execute it
if (isset($MM_insert)) {
// create the sql insert statement
$MM_tableValues = "";
$MM_dbValues = "";
for ( $i=0; $i+1 &lt; sizeof($MM_fields); ($i=$i+2)) {
$formVal = $MM_fields[$i+1];
$MM_typesArray = explode(",", $MM_columns[$i+1]);
$delim = $MM_typesArray[0];
if($delim=="none" $delim="";
$altVal = $MM_typesArray[1];
if($altVal=="none" $altVal="";
$emptyVal = $MM_typesArray[2];
if($emptyVal=="none" $emptyVal="";
if ($formVal == "" || !isset($formVal)) {
$formVal = $emptyVal;
}
else {
if ($altVal != "" {
$formVal = $altVal;
}
else if ($delim == "'" { // escape quotes
$formVal = $delim . $formVal . $delim;
//$formVal = "'" . str_replace("'","\'",$formVal) . "'";
}
else {
$formVal = $delim . $formVal . $delim;
}
}
if ($i == 0) {
$MM_tableValues = $MM_tableValues . $MM_columns[$i];
$MM_dbValues = $MM_dbValues . $formVal;
}
else {
$MM_tableValues = $MM_tableValues . "," . $MM_columns[$i];
$MM_dbValues = $MM_dbValues . "," . $formVal;
}
}
$MM_editQuery = "insert into " . $MM_editTable . " (" . $MM_tableValues . " values (" . $MM_dbValues . "";
if ($MM_abortEdit!=1) {
// execute the insert
$queryrs = $myJTI-&gt;Execute($MM_editQuery) or DIE($myJTI-&gt;ErrorMsg());
if ($MM_editRedirectUrl) {
header ("Location: $MM_editRedirectUrl";
}
}
}
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;/head&gt;
&lt;body bgcolor="#FFFFFF" text="#000000"&gt;
&lt;form method="post" action="&lt;?php echo $MM_editAction?&gt;" name="form1"&gt;
&lt;table border=0 cellpadding=2 cellspacing=0 align="center"&gt;
&lt;tr valign="baseline"&gt;
&lt;td nowrap align="right"&gt;DEPTID:&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="DEPTID" value="" size="32"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr valign="baseline"&gt;
&lt;td nowrap align="right"&gt;DEPTNAME:&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="DEPTNAME" value="" size="32"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr valign="baseline"&gt;
&lt;td nowrap align="right"&gt;&nbsp;&lt;/td&gt;
&lt;td&gt;
&lt;input type="submit" value="Insert Record" name="submit"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;input type="hidden" name="MM_insert" value="true"&gt;
&lt;/form&gt;
&lt;p&gt;&nbsp;&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;

Replies

Replied 27 Jan 2002 13:28:56
27 Jan 2002 13:28:56 Bruno Mairlot replied:
Dantic,

this first thing one may notice in your screenschot, is that dreamweaver see in the code the tag <b>&lt;/MM_RECORDSET&gt;</b> which is a tag that doesn't opens anywhere. That's why DW is getting confused.

This tag can not be found into your code, so I suppose it comes from somewhere in the code, where PHP code isn't correct.

This tag scrambles DW view right before the &lt;html&gt; tag. So, take some time to look at this part of the code to see why exactly this tag is shown.


Hope it helps.

Bruno

--- Better to die trying, than never try at all ---
Replied 28 Jan 2002 13:48:27
28 Jan 2002 13:48:27 Tim Green replied:
I know this problem *very* well.

The tag &lt;MM_RECORDSET&gt; is a specific tag used by UltraDev to mark a locked region of code.

Normally this is transparent to the normal user, but there are times when situations like this occur.

I mainly encounter it when I'm writing extensions....

The reason this normally happens for me is because I am writing PHP Code in a Site Profile that does not have PHP defined as the Application Server. Unfortunately, this is not the only change that occurs, as you'll probably also find the PHP Code Block tags are also URL_Encoded, and therefore don't look like regular PHP.

The only way around this, I'm afraid, is to delete all of the offending code in Code View and reapply the relevant behaviours.

I haven't seen this item mentioned here before... otherwise I would have picked up on it immediately.

This is not an issue with the code you have written, but with the UltraDev translators.

Question: Did you create this page originally with an earlier version of PHAkT?

If this is so, then it is likely that that is the cause of your consternation.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 28 Jan 2002 19:55:05
28 Jan 2002 19:55:05 darko antic replied:
Thanks Tim,

i figuered it was something more than a simple glitch so i did post that one earlier to the bugtracker at interakt, but there were no response hence this thread.
i just decided to work with window always screwed up, since i was in a rush to finish the project (this is the first time i used phakt so i didn't make pages with the previous version), but now maybe i'll spend more time to see if anything can be done with this.

Overalall i find phakt a bit buggie but does the job. Do you have any idea if the Impakt is better, and is it available for mac?
thanks
darko



Edited by - dantic on 28 Jan 2002 20:00:48

Edited by - dantic on 28 Jan 2002 20:04:56
Replied 30 Jan 2002 21:15:28
30 Jan 2002 21:15:28 Tim Green replied:
Darko,

I'm really a bit biased when it comes to IMPAkT, as I helped with some parts of it's development.

PHAkT is OK, and to be perfectly honest, the 'quirks' that exist in PHAkT now, are largely due to the fact that Macromedia didn't expect someone else to design a full PHP Server Model! (Even though they always said it could be done, not everything was possible as it should have been....)

Anyway. If you're new to using the PHP Server Model in the UltraDev environment, I would take my time, and get used to working with PHAkT, and then if you feel that you need the optimizations in IMPAkT, then go for it!

Anyway, that's my honest opinion, even if I have cheated myself out of some commission.

Oh, and yes, IMPAkT is available for the MAC too...... <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>


Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 11 Feb 2002 12:32:36
11 Feb 2002 12:32:36 david matson replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I know this problem *very* well.

The tag &lt;MM_RECORDSET&gt; is a specific tag used by UltraDev to mark a locked region of code.

Normally this is transparent to the normal user, but there are times when situations like this occur.

I mainly encounter it when I'm writing extensions....

The reason this normally happens for me is because I am writing PHP Code in a Site Profile that does not have PHP defined as the Application Server. Unfortunately, this is not the only change that occurs, as you'll probably also find the PHP Code Block tags are also URL_Encoded, and therefore don't look like regular PHP.

The only way around this, I'm afraid, is to delete all of the offending code in Code View and reapply the relevant behaviours.

I haven't seen this item mentioned here before... otherwise I would have picked up on it immediately.

This is not an issue with the code you have written, but with the UltraDev translators.

Question: Did you create this page originally with an earlier version of PHAkT?

If this is so, then it is likely that that is the cause of your consternation.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Replied 11 Feb 2002 12:42:53
11 Feb 2002 12:42:53 david matson replied:
Hi,

I am having the exact same problem. I just downloaded PHAkt yesterday and have been trying to get past this error for the past four hours.

The other posts here about making it work with a server really helped! But, every time I use the INSERT RECORD command it creates that locked code.

I am using the most current version and my admin server is set to php.

Thanks for any help,

David Matson

Reply to this topic