I have been trying to figure out how to populate a html template with data from a multi dimensional array, but i cant figure it out. The template is taken from MySQL. This is what I have: $template=addslashes($row['content']); eval("\$body=\"$template\";"); print($body); Now the template is as follows: $row['content'] = "<html><p>array item one $arr[0][0]</p><p>array item two $arr[0][1]</p></html>" ...and the array ($arr): Array ( [0] => Array ( [0] => 1 [1] => 6 ) ) The result is: $body = <html><p>array item one Array[0]</p><p>array item two Array[1]</p></html> ...as opposed to what I expected: $body = <html><p>array item one 1</p><p>array item two 6</p></html> …

Member Avatar
Member Avatar
+0 forum 2

I googled little around for correct way to not reinventing of the wheel for expression evaluation (even I had done some simple evaluation check for my [Tkinter calculator snippet](http://www.daniweb.com/software-development/python/code/282548/simple-calculator) earlier). After getting totally upset with [this example](http://www.bestcode.com/html/evaluate_math_expressions_pyth.html), I made this with some struggles with `__builtins__` globals parameter of eval. First I kept the dictionary of variables approach, then I turned to keyword parameters, the format is so much nicer. To put some topping, I put `__call__` also as synonym for evaluation. That means you can call the class as functions and give any values of variables as keyword parameters. See …

Member Avatar
+0 forum 0

I am trying to write safyfied evaluator class, and get unexpected `__builtins__` added to dictionary after evaluation. Can somebody explain why/how it happens? import math def echo(n): print n return n def nothing(n): return n debug = nothing class MathParser(object): ''' Mathematical Expression Evaluator class. call evaluate() function that will return you the result of the mathematical expression given as a string when initializing. math library functions allowed, no __ allowed ''' __slots__ = 'expression', 'variables', 'math' def __init__(self, expression, variables=None): self.math = dict((a,b) for a,b in math.__dict__.items() if not a.startswith('__') and '__' not in str(b)) assert '__builtins__' not in …

Member Avatar
Member Avatar
+0 forum 3

In my code they're instructed to enter a width and height. However obviously these will be intergers, but I need to perform checks that they are intergers before they're used. Atm I've got this: [CODE] while True: if width.isdigit() == True and height.isdigit() == True: if width >= 2 and width <= 8: if height >= 2 and height <= 8: break else: width, height = eval(input("Enter the width and height of patches: (e.g. 6, 3) ")) else: width, height = eval(input("Enter the width and height of patches: (e.g. 6, 3) ")) else: print("You have entered word(s) rather than numbers")[/CODE] …

Member Avatar
Member Avatar
+0 forum 11

Hi, I am new to Unix/Linux... I have a TCSH shell script (on AIX4) in which, at a certain point, I want the user to be able to pass commands to the TCSH interpreter. What I do is I create the illusion that the user is at his usuall shell prompt : echo -n `whoami`"> "; set cmdinput = "$<"; After reading the standard input from key board, I want to "execute" within the shell, the command typed by user. Note that I run my script with >source myscript.tcsh to ensure it running from the current shell (unlike >tcsh myscript.tcsh). …

Member Avatar
Member Avatar
+0 forum 1

Hi, I'm new to ASP.NET. I began learning as I had to make a website for a college project using a language I didn't already know (I know PHP pretty well so I'm not a total noob :P). Basically what I'm trying to do is get a list of products, display them and then display all the comments for each product. So I have a ListView for getting all the products, but I want a DataSource inside the ListView with the search string being something like "SELECT * FROM comments WHERE prod_id = Eval('prod_id')". Obviously that doesn't work with the …

Member Avatar
Member Avatar
+0 forum 1

Hi All, I'm using SOAP::Lite to do some online payments. The whole mechanism is set on separate machine which is communicating with payment gateway. So WWW machine sends a message to invoke SOAP::Lite and SOAP message is sent to payment gateway. In development I had both "machines" running on one (separate instances) and there was no problem, but the moment it went on two separate machines I got this error from SOAP::Lite : Code execution error: Method [ method_name ] returned error: Insecure dependency in eval while running with -T switch at /usr/lib/perl5/site_perl/5.8.8/SOAP/Lite.pm line 3225 Any idea? Milos

Member Avatar
Member Avatar
+0 forum 2

Hello, I am newbie at ASP.net. I got stuck at a point that hopefully you can help me. I use mssql as database and fetch all my records and images from there by using <asp:SqlDataSource>. I also use [CODE]<asp:Repeater>[/CODE] to show data at every iteration. After fetching data from database, it is easy to show string by using [CODE]<%# Eval("someData") %>[/CODE]. but how can i show the data that comes as image type from database? It is not possible to show an image like this[CODE] <img src="<%# Eval("imageTypedData") %>" />[/CODE] :( Because image source needs an url! My source code …

Member Avatar
Member Avatar
+0 forum 2

[CODE]cmd='date | wc' $cmd [/CODE] If this script is executed, an error is generated. The reason written was that "The execution fails because the pipe is not expanded and is passed to date as an argument". What is meant by expansion of pipe. When we execute [B]date | wc[/B] on the command line, it goes fine. then | is not treated as an argument. Why? Works correctly using eval though! How?

Member Avatar
+0 forum 0

This function I did to improve calculator program by eliminating problems with Pythons problem of dividing integer with integer and giving integer division result.

Member Avatar
Member Avatar
+0 forum 5

The End.