i am trying to convert a php code to cf, here is m...
# cfml-general
g
i am trying to convert a php code to cf, here is my try please guide and correct me if i done anything wrong, i am not getting the right results here https://cffiddle.org/app/file?filepath=e9d5300f-28ec-4087-add8-61bbc2bf4f39/58495be[…]067-bf35-2fea2659f5e5/e5154b42-b117-42c7-9699-75b1a90722fc.cfm
t
for(data as row)
is not valid... and what you actually want depends on what type
data
is. I'm guessing that it's a query, so it should be
for(row in data)
also, in line 35, you have a stray
-
between
row
and
[
.
and this code is weird to boot.... why are you assigning values to the row, and where are they coming from? It seems like it ought to be something more like:
Copy code
for(row in data) {
   modified_data = {
       "updated_at": row["updated_at"],
       "Status": row["Status"],
       "Date Approved": row["Date Approved"],
       ...
   };
}
a
@Tim I recommend not indulging this sort of question. @gsr no. Do yer own work, and when you are stuck with some CFML that doesn't do what you expect, then come and ask a question about that. We're not here to be your brain.
g
@tim thedata is basically from here data = fileread('../Data/' & source & '.json'));
so its an array of structs being returned
t
adam's right on this one, and you need to do a bit more work and come back with specific errors/questions. But as a clue, fileRead returns a string, not an array of structs....
g
anyways, if not willing to help, no Issues, i will figure out, Thanks anyways @Tim
a
We're all willing to help, @gsr. That is different from "doing your work for you".
g
if there is a willingness, then should have helped, because i tried from my end to try to convert that code to cf
t
I haven't even tried running this code, and because you have the PHP in there, it's not like I can even just run the gist you sent.... And even so, I've found at least 3 syntax errors that i've already told you about. It's a mess, and it's not even clear what you're trying to do. And I don't mean "rewrite the php into cf." I mean "what is the php doing?" line 29: data undefined. also line 29: syntax error near "as" line 30: reqId undefined. line 32: $time undefined (did you mean "time" as defined in 31?) and while not technically an error, row should probably be treated as immutable, so trying to assign it a value is weird. line 33: $rowStatus undefined line 35: syntax error near "[" line 37: style undefined We can help you if you have a specific problem you can't figure out. But this isn't a specific problem. I've outlined a bunch of problems, and I don't know which ones you know how to fix, and which ones you don't, because you haven't asked about any of them. But all of them are things that should be fairly obvious if you try to run the code, which implies that you did not....
g
this is ful php code https://pastebin.com/6HShQYYG and this is my trying to convert it https://pastebin.com/n9D2AUwJ and i am trying my best as i can.
a
You absolutely are not trying the best you can, Gavy. For years I've been making the same suggestions: read this http://www.catb.org/~esr/faqs/smart-questions.html; read this: http://sscce.org/. Act on them. Keep your questions focused. Provide code that runs that demonstrates a particular issue, and describe the issue. Clearly. You have never done any of that. All you do is post "can you do my work for me" or "code doesn't work fix please" every coupla weeks. Put some effort in, if you expect us to put some effort in.
g
Adam When I don’t respond I try to do offline And usually I do not respond online because I know I will not getting any guidance
a
Good on you for going stuff offline. This does not detract from the fact you put zero effort in here when you ask for us to do your work for you. You will get guidance if you put some effort in.
t
case in point.... did you notice that line 1 of your "coldfusion example" starts with a php directive instead of a <cfscript> tag? This is not the sort of stuff we should have to point out.