Skip to main content
November 15, 2007
Answered

Strange PHP code generated

  • November 15, 2007
  • 4 replies
  • 339 views
I am attached a some generated code from DW CS3 using PHP. I'm not a PHP expert but just looking at the code you can see the same function "GetSQLValueString" declared over and over again. On one page I saw this defined 5 times, removed 4 of the definitions and then my page was able to display. I know that's not a full explanation, maybe I deleted some brackets that were causing problems, but the point is that it's all DW generated code. Please see the attached code if you're a PHP expert and can maybe shed some light for us pedestrians. Are there any Adobe experts out there on this board? There used to be but it's looking like a deserted board lately.
This topic has been closed for replies.
Correct answer Newsgroup_User
"davidbarrackphoto" <webforumsuser@macromedia.com> wrote in message
news:fhi56c$pfi$1@forums.macromedia.com...
> I am attached a some generated code from DW CS3 using PHP. I'm not a PHP
> expert but just looking at the code you can see the same function
> "GetSQLValueString" declared over and over again. On one page I saw this
> defined 5 times, removed 4 of the definitions and then my page was able to
> display. I know that's not a full explanation, maybe I deleted some
> brackets
> that were causing problems, but the point is that it's all DW generated
> code.
> Please see the attached code if you're a PHP expert and can maybe shed
> some
> light for us pedestrians. Are there any Adobe experts out there on this
> board?
> There used to be but it's looking like a deserted board lately.

That code was added to prevent SQL injection problems with the previous PHP
MySQL implementation,
why on earth they chose to include it over and over again instead of using
an include or putting it in the connection file is beyond me..


4 replies

Inspiring
November 15, 2007
> Well after wasting a day I found that this block of code keeps getting
> added
> whenever I touch a recordset (open and close it for example). For
> whatever
> reason this is causing my page to display a blank page each time DW adds
> another repetition. I then go in and delete it and alas my page works
> again.
> This must be a bug and I'm not sure why I am just now seeing my pages not
> display. For those looking at this, here is the code that I have to keep
> removing:

I think you're slowly learning why not to depend on software to write code
for you. ;o)

-Darrel


Inspiring
November 15, 2007
"davidbarrackphoto" <webforumsuser@macromedia.com> wrote in message
news:fhi8d8$8h$1@forums.macromedia.com...
> Well after wasting a day I found that this block of code keeps getting
> added
> whenever I touch a recordset (open and close it for example). For
> whatever
> reason this is causing my page to display a blank page each time DW adds
> another repetition. I then go in and delete it and alas my page works
> again.
> This must be a bug and I'm not sure why I am just now seeing my pages not
> display. For those looking at this, here is the code that I have to keep
> removing:

Somehow the code isn't identified as a Serverbehavior's participant and gets
added again and again when the serverbehavior is applied, did you change the
dreamweaver generated code in any way?
Installed any extensions that might have changed the edml files?
Created custom serverbehaviors that may interfere with the standard
dreamweaver ones?



November 15, 2007
Well after wasting a day I found that this block of code keeps getting added whenever I touch a recordset (open and close it for example). For whatever reason this is causing my page to display a blank page each time DW adds another repetition. I then go in and delete it and alas my page works again. This must be a bug and I'm not sure why I am just now seeing my pages not display. For those looking at this, here is the code that I have to keep removing:

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . date("Y-m-d",strtotime($theValue)) . "'" : "NULL";
break;
case "time":
$theValue = ($theValue != "") ? "'" . date("H:i:s",strtotime($theValue)) . "'" : "NULL";
break;
case "datetime":
$theValue = ($theValue != "") ? "'" . date("Y-m-d H:i:s",strtotime($theValue)) . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
Newsgroup_UserCorrect answer
Inspiring
November 15, 2007
"davidbarrackphoto" <webforumsuser@macromedia.com> wrote in message
news:fhi56c$pfi$1@forums.macromedia.com...
> I am attached a some generated code from DW CS3 using PHP. I'm not a PHP
> expert but just looking at the code you can see the same function
> "GetSQLValueString" declared over and over again. On one page I saw this
> defined 5 times, removed 4 of the definitions and then my page was able to
> display. I know that's not a full explanation, maybe I deleted some
> brackets
> that were causing problems, but the point is that it's all DW generated
> code.
> Please see the attached code if you're a PHP expert and can maybe shed
> some
> light for us pedestrians. Are there any Adobe experts out there on this
> board?
> There used to be but it's looking like a deserted board lately.

That code was added to prevent SQL injection problems with the previous PHP
MySQL implementation,
why on earth they chose to include it over and over again instead of using
an include or putting it in the connection file is beyond me..