Scriptcase went funny

Dear Scriptcase-Team,

since 3 weaks I am working on an application. Among other mysterious things, today, everythings went down the drain.
I call my application and the following error occours:

Trying to get property of non-object | Script: /var/www/scriptcase/devel/class/xmlparser/nmXmlparser.class.php linha: 192

The application is compiled and executed, but not correctly!

  • 3 Buttons were deleted,
  • The Code in one Button is vanished (Code see below),
  • The Blocks (about 25) have losted their arrangement and trying to rearrange them does not succeed! The loose their order. Adding many Blocks makes it possible to rearrange and save them!

The Code of the above mentioned button is listed below.

!!! It took me over 3 weaks on work (about 150 hours of work). Please help me, what have I done wrong. Is it a bug, is their a Fix for that??

Desperatly greating,

Hydro…


if ([SearchType] == “Nachfrage”)
{

$str1 = "";
$all_results = "";
$all_results_with_AND = "";
$all_results_with_OR = "";
$all_results_with_NOT = "";

$arr = array(
	"Descr_ID" => 			array (	"Descr_ID"),	 
	"Description" => 		array (	"Description"),
	"Type" => 			array (	"Type"),					 
	"Wert" => 			array (	"Wert"), 
	"Mandatory" => 			array (	"Mandatory"),
	"Reihenfolge" => 		array ( "Reihenfolge"),   
	"Level" => 			array (	"Level"),
	"Einheit" => 			array ( "Einheit"),
	"Toleranz"=>			array ("Toleranz"),
	"LogicOperator"=>		array ("LogicOperator")
);

if ({Kriterium2} <> "")
{
		sc_lookup(Value, "SELECT DISTINCT Type, Descr_ID, Description, Mandatory, Reihenfolge, Level, Einheit FROM eingabemasken WHERE Descr_ID='{Kriterium2}'");
		$str1 = "";
		if ( {Value[0][0]} == "zahl" AND {Krit2von} <> "" AND {Krit2bis} <> "")
		{
			$str1 = "SELECT DISTINCT Inserat_ID FROM market WHERE Kat_ID=" . {Kriterium1} . " AND Descr_ID='" . {Kriterium2} . "' AND Value >= " . mysql_real_escape_string({Krit2von}) . " AND Value <= " . mysql_real_escape_string({Krit2bis}) . "";		
			$arr["Wert"][2] 	= ({Krit2bis} + {Krit2von}) / 2;
			$arr["Toleranz"][2] 	= {Krit2von} - ({Krit2bis} + {Krit2von}) / 2;
		}
		if ({Value[0][0]} == "text" AND {Krit2Contains} <> "")
		{
			$str1 = "SELECT DISTINCT Inserat_ID FROM market WHERE Kat_ID=" . {Kriterium1} . " AND Descr_ID='" . {Kriterium2} . "' AND Value LIKE '%" . mysql_real_escape_string({Krit2Contains}) . "%'"; 
			$arr["Wert"][2] 	= mysql_real_escape_string({Krit2Contains});
		}
		if ({Value[0][0]} == "janein")
		{
			$str1 = "SELECT DISTINCT Inserat_ID FROM market WHERE Kat_ID=" . {Kriterium1} . " AND Descr_ID='" . {Kriterium2} . "' AND Value LIKE '" . {Krit2janein} . "'"; 
			$arr["Wert"][2] 	= {Krit2janein};
		}
		$arr["Type"][2] 	= {Value[0][0]};
		$arr["Descr_ID"][2] 	= {Value[0][1]};
		$arr["Description"][2]	= {Value[0][2]};
		$arr["Mandatory"][2]	= {Value[0][3]};
		$arr["Reihenfolge"][2]	= {Value[0][4]};
		$arr["Level"][2]	= {Value[0][5]};
		$arr["Einheit"][2]	= {Value[0][6]};
		$arr["LogicOperator"][2] = {Krit2Operator};
}
$criteria = $arr;
sc_lookup(Ins, "SELECT MAX(Inserat_ID) AS New_Inserat_ID FROM market");
$Inserat_ID = $Ins[0][0];
$Inserat_ID = $Inserat_ID + 1;
$i=2;
while($i<=9)
{
	if ($criteria["Descr_ID"][$i] <> "" OR $criteria["Wert"][$i] <> "")
	{
		$sql_cmd = "INSERT INTO market (Vorfall, Inserat_ID, gultig_bis, User_ID, Kat_ID, Descr_ID, Description, Type, Value, Mandatory, Reihenfolge, Level, Einheit, Toleranz, KeepLooking, LogicOperator) VALUES ('Nachfrage', '$Inserat_ID', '{Nachfrage_bis}', '[User_ID]', '{Kriterium1}', '" . $criteria["Descr_ID"][$i] . "', '" . $criteria["Description"][$i] . "' , '" . $criteria["Type"][$i] . "' , '" . $criteria["Wert"][$i] . "', '" . $criteria["Mandatory"][$i] . "', '" . $criteria["Reihenfolge"][$i] . "', '" . $criteria["Level"][$i] . "', '" . $criteria["Einheit"][$i] . "', '" . $criteria["Toleranz"][$i] . "', '" . {KeepLooking} . "', '" .	$criteria["LogicOperator"][$i] . "'))";			
		sc_exec_sql($sql_cmd);
	}
	$i++;
}
$sql_cmd = "INSERT INTO market_beschreibung (Inserat_ID, User_ID, Titel, Beschreibung) VALUES ('$Inserat_ID', '[User_ID]', '" . {Gesuche_Titel} . "', '" . {Gesuche_Beschreibung} . "')";			
sc_exec_sql($sql_cmd);

Re: Scriptcase went funny

Not sure how to answer this … sorry to hear about your problem. I have seen the XMLparser errors myself on a few occasions. (using linux as well)
Hopefully you have a backup of your project (export project, and settings/backup)

Also, your mysql holds all of the data for the apps. Hopefully you have a backup of your DB’s. Create a cron job if not.
I also have rsnapshot setup to backup in a cron job that includes SC5 and mysql.

Never trust another app to preserve your code.

I have seen a few articles about xmlparser, but not sure if it will help:

http://php.net/manual/en/book.simplexml.php

To add to what others have said, you can’t directly put a $_GET or $_POST value into a variable then into an attribute using SimpleXML. You must first convert it to an integer.

This will NOT work

<?php
$page_id = $_GET[‘id’];
echo $xml->page[$page_id]
?>

You will get something like:
Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/mysite/index.php on line 10

However, this WILL work and is much simpler then using (string) or other methods.
<?php
$page_id = intval($_GET[‘id’]);
echo $xml->page[$page_id]
?>

Perhaps this is something that NetMake is doing when they generate the code and not related to your code directly.

Regards,
Scott.

Re: Scriptcase went funny

Another thing to consider …

Have you tried to export, delete, then import the app back? I have seen this work to correct drawing issues.
(or perhaps import into a new test project before you delete anything)

Regards,
Scott.

Re: Scriptcase went funny

Hi Scott,

Thx for your reply.
gladly, I created lots of backups because I recognized scriptcases chaotic and instable behaviour in an earlier project.

I tried a lot like restoring and re-importing my application back. Interesting; I can reproduce this error, by reinserting back the above posted Code into the button and compiling the application. The effect is always the same: Code vanished, empty Button (no function and not contained in the source code)

But your answer gives me a hint, to what I was afraid of. It must coincedence with the variables. I had a lot of troubles by passing datas from one app to the others.

You wrote:

$page_id = intval($_GET[‘id’]);
echo $xml->page[$page_id]

I got two difficulties:

  1. intval creates an integer (numeric). What is to do, if I wanted to pass a string?
  2. generally: where have i done a simiular mistake in my code. I am very unexprerienced in php…

Regardy,

HYdro

Re: Scriptcase went funny

strval() is for strings.

When trying to find code problems, I will usually add/remove sections of the code until I find the culprit.
Perhaps add the code in sections until to duplicate the behavior to narrow it down.

My first guess is a reserved word or a misplaced quote.

Regards,
Scott.

Re: Scriptcase went funny

I have seen that this error is shown when I try to open published apps in the same browser where I am developing (where SC is open).

If this is your case. open your created app in another browser (not other window)