FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


execute php string





flatliner
hey every1, ok well I have this script, well its one big fucntion really, I didnt write it and I dont fully understand it. The problem I have is this function outputs its resluts by

Code:


 $data = my_function($arugment);

return $data;


The variable $data is around 50 or so sql insert querys, how can I execute that string on the same page? I dont know if I have explained it very well, but its the best I can do for the mo.

Kind Regards
Ciaran Mc Cann
Manofgames
You mean $data is a string containing 50 queries?
flatliner
yes, ready to be executed, with no slashes or anything, all it need is to be run.
roboguyspacedude
maybe give a link of this page so we can see what it echos and determine it from there.
flatliner
I would but the information is sorta confodential, below is an explain of what is in the string

Code:


mysql_query("INSERT INTO planning_applications(FILE_NUMBER,APPLICANT_NAME,APPLICATION_TYPE,APPLICATION_RECEIVED,DEVELOPMENT_DESCRIPTION,DEVELOPMENT_LOCATION,DECISION_DATE,DEVELOPMENT_TYPE,PROTECTED_STRUCTURE,WASTE_LICENCE,RECEIVE_MARKETING_MATERIAL) values('file','name','type','date','description','dates','info',NULL,'NO','NO')") or die(mysql_error())

mysql_query("INSERT INTO planning_applications(FILE_NUMBER,APPLICANT_NAME,APPLICATION_TYPE,APPLICATION_RECEIVED,DEVELOPMENT_DESCRIPTION,DEVELOPMENT_LOCATION,DECISION_DATE,DEVELOPMENT_TYPE,PROTECTED_STRUCTURE,WASTE_LICENCE,RECEIVE_MARKETING_MATERIAL) values('file','name','type','date','description','dates','info',NULL,'NO','NO')") or die(mysql_error())

mysql_query("INSERT INTO planning_applications(FILE_NUMBER,APPLICANT_NAME,APPLICATION_TYPE,APPLICATION_RECEIVED,DEVELOPMENT_DESCRIPTION,DEVELOPMENT_LOCATION,DECISION_DATE,DEVELOPMENT_TYPE,PROTECTED_STRUCTURE,WASTE_LICENCE,RECEIVE_MARKETING_MATERIAL) values('file','name','type','date','description','dates','info',NULL,'NO','NO')") or die(mysql_error())

etc....

Manofgames
eval() wrote:

eval()

(PHP 4, PHP 5)

eval Evaluate a string as PHP code
Description
mixed eval ( string $code_str )

Evaluates the string given in code_str as PHP code. Among other things, this can be useful for storing code in a database text field for later execution.

flatliner
yes I came across that but I dont think its wat I am looking for tho but I will try it, thanks.
phpc0d3r
So the $data contains all of these mysql_query() commands or just SQL Strings waiting to be executed...

If it's SQL you could write

Code:

mysql_connect('localhost', 'user', 'pass') ;

mysql_select_db('whatever');

foreach($data as $query){
    mysql_query($query) or die(mysql_error);
}

mysql_close();
flatliner
yes I think you would be right in saying that alright, although I have come up againest another problem in using that method, although lucky I found a complete different method of doing the task and it works fine now. thanks for all the help every1

Kind regards
Ciaran Mc Cann
jabapyth
i think eval is disabled in frihost.
Related topics
php includes
PHP/Mysql - beginner!
Why is this happening ??
what plugin you used on your Wordpress
Replacement of hexadecimal values in PHP string
can someone make me a members loginscript?
Excel SpreadSheet to Website
PHP ristriction on Output
[HELP] Using SMF on Server 2
Sluchawki
Get specific parts of a string
hashing your passwords
is it possible to get a html text box to load a .txt file?
PHP String formatting
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.