logs archiveIRC Archive / Freenode / #php / 2006 / June / 7 / 26
kavok
Im having a problem. I have a text area that the user dumps some XML into then xml_parse_into_struct tries to use the textarea (via $_POST) as its second parameter (string) however its not working.
alystair
of course they are sending a text string that says "null" :P
kavok
If I actually put the XML file INTO the php code an assign it to a variable it works fine, what gives?
wobbles
kavok: What does the POST value look like if you var_dump it?
kavok
Whats var_dump? lol
wobbles
Oh. OK. Wasting my time here. I think
kavok
wobbles: If you mean echo'ing the variable? It looks just like it should look. Of course my browser its the XML tags, so I have to view source to see it properly.
wobbles
kavok: No, I meant var_dump.
Lietu
kavok: he means var_dump($var) or print_r($var)
         

kavok
I've never heard of var_dump
Viper007Bond
what in the hell does this mean: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in
CPUnerdX
:P
Vlet
Viper007Bond: http://www.pastebin.com/
BigE
Viper007Bond: You have something else where PHP expects a string.
jamiel
Vlet : Great, I got it working thanks. You were correct. foreach ($rootNode->children() as $name => $value) $rootNode->$name = 'foo';
Vlet
woot :)
Viper007Bond
oh
i got it
hit backspace a few too many times like 10 lines up
BigE
Heh.
Viper007Bond
guess that's what i get for coding at 6am
Vollstrecker
Is it possible to explode a string, and give keys for the fields?
BigE
Eh, that's what we all get for coding that early.
Viper007Bond
(Action) turns the trance up to wake him up
BigE
Vollstrecker: Sure... use explode() and list()
Vollstrecker
Something like explode and selfdefined keys
BigE
$data = 'foo bar'; $array = array(); list($array['Key1'], $array['Key2']) = explode(' ', $data);
kavok
var_dump = string(353) followed by the XML file (the only difference is the XML declaration is in quotes for some reason)
Vollstrecker
explode("_", "0_1_2) gives 0 => 0 and so on. I want it like first_level => 0, second_level => 1
kavok
@wobbles: Does that help any?
BigE
Vollstrecker: Yes, you can do that with list() using the method I just gave you. If it's not always going to be the same length of data, then you'd have to implement a foreach() loop or something.
         

Vollstrecker
I see
kavok
I think it needs to be arraystring and not string
Well how do I turn a string into an arraystring
trovster
To make a URL out of a title, I want to replace spaces with dashes, and only allow a-z0-9 I have - this & that or not - how can I convert that to - this-that-or-not ?
$array = array($string); ?
__DunK__
hi
does anyone know of an editor other than emacs that will auto indent a line of php at the press of a button (tab in emacs)
ZbouhhhTaff
great feature of emacs
xemacs ?
eclipse does it ( ctrl+i on selected text ) but that is not perfect
cocomp
CTRL-Shift-F in Zend Studio
Wolfpaws
__DunK__: kwrite / KATE
Vlet
there's a setting your can assert in the config file for nano to have it do that
I like nano cause it's really 'kiss'
kavok
I still can't get this working... I can read the XML from a file or straight from the code but not from a <textarea></textarea>.. which is really the most efficent way at the moment.
I've tried $data = array($_POST[blah]) but that doesnt work
Vlet
what xml library are you using?
simpleXML?
cocomp
var_dump($_POST['name_of_field_in_form']);
kavok
Vlet: Whichever one isn't simpleXML :)
cocomp: Is that for me?
Vlet
uh
cocomp
kavok: yep
Vlet
kavok: DOM?
kavok
Vlet: I don
__DunK__
i'm on windows: it's a bit of a problem
kavok
Vlet: I don't know?
string(353) <-- thats what the textarea comes in as
Im trying to use it in a xml_parse_into_struct as the second parameter
__DunK__
either the implementation on win32 is broken, or the php setup in xemacs(yes, x) is really bad
Vlet
well, paste some code to http://pastebin.com/
__DunK__
the second nested tag does not get indented, it's infuriating
cocomp
and you're accessing the $_POST['variable_name'] correctly when passing it, not just $_POST ??
Vlet
__DunK__: Check out nodepad2: very lightweight, basically just syntax highlighting and indentation
kavok
http://pastebin.com/765134
Crescendo
Nodepad? =D
aibo
hello all, I have some post-form: http://pastebin.com/765131 and I am using curl to submit it, but THERE ARE "=" in var and I dunno if curl correctly sends this argument...I get wrong result after submit...I tried to 'urlencode' this arg, but nothing happened...:(
kavok
and this is the sample XML: http://pastebin.com/765024
cocomp
try $_POST['xml'] instead of $_POST[xml]
kavok
If you want a good lighteight thing to write your code on get textpad, for windows atleast
cocomp: The data -is- getting though, it just isnt being used..
cocomp: As far as I can see that didnt change anything :(
cocomp
well it won't hurt at least
also what are you trying to do with $data = implode("", array($data)); ?
Vlet
kavok: Why do you: $data = implode("", array($data));
Nathe
kavok: **shudder** gvim ftw! ;)
kavok
Well the example I have that -works- uses implode("", file(filename.xml)); so I decided to try changing the textarea into an array then imploding it
Nathe: I just emerged vim but I havent started using it yet
Im normall very identy
I've tried with/without the implode, doesnt seem to change anything
Vlet
No need. by saying $data = $_POST[xml]; you have the xml in $data. Now go parse it. don't fudge it up
kavok
Well it doesnt change the overall result
cocomp
comment out the implode - not needed in this instance
wobbles
kavok: POST elements are strings, not arrays
kavok
okay I've gotten rid of it
wobbles: ?? Whats that have to do with anything
arpad
POST elements can be arrays too anyway
wobbles
Not in this caase - poorly worded on my part
kavok
If I stuff the same XML into code and assign it to a variable, or use a file, I can get this working
But I really want to use it from the textarea inptu
input*
wobbles
kavok: Well, check the value you get at each step of the process, for starters
Shane-S
I need help with sessions, I have a long if branch, that checked for a session variable, if its not TRUE it will go on. When I login, the value is true, but if I go to the URL again from my browser the echo doesn't even do a thing. I will pastbin my code...brb
kavok
wobbles: I thought I was? Im not dealing with that many variables
cocomp
try var_dump($tags, $values); just after the parse_into_struct
le_neko
really fast question please
cocomp
also try initialising $i before using it
kavok
cocomp: Both array(0) { }
wobbles
howmanybeansmakefive?
ZbouhhhTaff
le_neko > laquelle ?
le_neko
is there function to turn this : 1 into this 01 ?
ZbouhhhTaff
wobbles > 5
kavelot
I want my PHP code to do something slow (like sleep(10)), but before I need to be sure it has print "please wait" to who is accessing this page... is it possible to guarantee the message will be show (something like an fflush(stdout) on C)?
ZbouhhhTaff
le_neko > not that I know about
cocomp
le_neko: str_pad
le_neko
thanks cocomp :)
kavok
I started $i before the loop, no effect
It says it needs a string, im giving it a string, I have no idea what im doing wrong.
brokencard
is it possible to have a regular expression that replaces and matches?
Shane-S
here is my code, I thin it has to do with my index.php's session_start() http://pastebin.com/765151
kavok
However when I vardump the imploded $data on my 'working' example (the one using a file) it shows up as an Arraystring, not an array or a string
McFly
kavok: flush() ?
kavelot: ^^
Shane-S
what happens is index.php show a login, you fill it out, and you logged in and $_SESSION['my_logged'] echos out as 1. Go in the address bar back to index.php and the login re-appears
wobbles
kavelot: flush might work
kavok
So does anyone have any ideas how to get this working? :(
kavelot
worked! :D
thanks
McFly
brokencard: preg_replace_callback will
brokencard
with this expression, how could I get it to replace all ampersands with 'and' while still returning the sting?
string
preg_match_all("/(<b>)([a-zA-Z0-9\s-_\.\:\&]*)(<\/b>)/is", $string, $match['company_name'], PREG_SET_ORDER);
is it even possible?
cocomp
Shane-S: try without the if (!session_id()) stuff and do a test on a session variable instead - e.g. always call session_start
kavok
So is that a no?
I could take the text area, write it to a temp file, implode it, clear the temp file, and then do it
But thats horrible :\
cocomp
xml_parse_into_struct takes strings as the second argument - so should be no problem
Shane-S
session_start won't re-make a users session?
cyth[work]
no
cocomp
session_start picks up the existing users session if it exists or creates one otherwise
cyth[work]
it just sets the headers to use sessions
kavok
cocomp, but its not working. Its not creating the two arrays for some reason
MariusX
hello ppl. I am trying to setup a php page that sends out a HTML email. I am having no luck with anything I have found in google. can someone help me out
Shane-S
that worked thanks
McFly
MariusX: http://phpmailer.sourceforge.net/
cocomp
Shane-S: :)
Shane-S
I got the !session_id() from a tutorial, does that require something special?
cyth[work]
MariusX, you have to use the headers argument in mail to state a text/html mime type
gotta take off bbl
MariusX
I had specified the MIME header.
Shane-S
wasn't clear what it did, other then the tutorial said it identifies the users session and makes sure it is there.
wobbles
MariusX: Look at http://phpmailer.sourceforge.net/
McFly
wobbles: too slow :)
wobbles
Oh, late again
MariusX
I can't have had it set up correctly though. does anyone have a working basic example. looking at that page now
Jorsha
what is the best function to encode password? MD5 ?
McFly
encode or emcrypt ?
fourmi
rot13 ;)
Alija-
Can someone tell me why isnt this working: http://pastebin.com/765191
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 next »