Hopefully some here know both ASP and PHP. I'd like to know if it's possible to do something akin to the code below in PHP.
---ASP Page---
<%@enablesessionstate="false" language="javascript"%>
<html>
<head>
<title>Execute Database Stored Code Test</title>
</head>
<body>
<script runat="server" language="javascript">
var str_TestVar = "How are you?"
var lng_CodeID = Request.QueryString("CodeID"
if (!isNaN(lng_CodeID)){
var obj_Connection = Server.CreateObject("ADODB.Connection"
obj_Connection.Open("driver={SQL Server};server=hrwbausdev1;database=test1;uid=sa;pwd=<sa pwd>"
var obj_Recordset = obj_Connection.Execute("select C_Body from A_Code where C_CodeID=" + lng_CodeID);
if (!(obj_Recordset.BOF && obj_Recordset.EOF))
eval(obj_Recordset.Fields("C_Body".Value);
obj_Recordset = null;
obj_Connection = null;
}
</script>
</body>
</html>
---SQL Server Script---
create database test1
use test1
create table A_Code (C_CodeID int identity(1,1) not null primary key, C_Body varchar(8000) not null)
insert A_Code (C_Body) values ('Response.write(''Hello World. '' + str_TestVar)')
---end---
In essence this is just reading a string from a database field which happens to be executable code, and dynamically executing in within the page. Can it be done in PHP?
PS I've just started learning PHP and have yet to actually code anything in it. exec() initially sounded like the go, but not sure if it can execute a string as well as a file?
codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>
---ASP Page---
<%@enablesessionstate="false" language="javascript"%>
<html>
<head>
<title>Execute Database Stored Code Test</title>
</head>
<body>
<script runat="server" language="javascript">
var str_TestVar = "How are you?"
var lng_CodeID = Request.QueryString("CodeID"
if (!isNaN(lng_CodeID)){
var obj_Connection = Server.CreateObject("ADODB.Connection"
obj_Connection.Open("driver={SQL Server};server=hrwbausdev1;database=test1;uid=sa;pwd=<sa pwd>"
var obj_Recordset = obj_Connection.Execute("select C_Body from A_Code where C_CodeID=" + lng_CodeID);
if (!(obj_Recordset.BOF && obj_Recordset.EOF))
eval(obj_Recordset.Fields("C_Body".Value);
obj_Recordset = null;
obj_Connection = null;
}
</script>
</body>
</html>
---SQL Server Script---
create database test1
use test1
create table A_Code (C_CodeID int identity(1,1) not null primary key, C_Body varchar(8000) not null)
insert A_Code (C_Body) values ('Response.write(''Hello World. '' + str_TestVar)')
---end---
In essence this is just reading a string from a database field which happens to be executable code, and dynamically executing in within the page. Can it be done in PHP?
PS I've just started learning PHP and have yet to actually code anything in it. exec() initially sounded like the go, but not sure if it can execute a string as well as a file?
codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>