Forum Moderators: coopster

Message Too Old, No Replies

$ GET variable only working in part.

         

php4life

10:20 pm on Aug 6, 2009 (gmt 0)

10+ Year Member



I have a form to be edited and re-submitted into my db. I did have this working, except now i cant seem to pass the get variable properly.
I click on the post to edit it and i use the GET variable to bring the id number of the post across to an edit.php page, which works fine and i then echo out the info out into a form to be edited and re-submited, except when i resubmit it, the get variable isnt used and in affect i have no id to update the post with. I am calling the variable after my mysql connect funstion and before my sql query. And the SQL query doesnt fail either, i've done a hard update, updating the `id` as a number say `id`='12' - and that works fine, the info in row 12 updated fine, so i cant seem to see why the GET variable is failing here?

It was working fine, but i fiddled with something and then tried to set it all back and now it doesnt work.

Can anyone shed some light?

php4life

10:38 pm on Aug 6, 2009 (gmt 0)

10+ Year Member



I can show the code if u wish too?

idfer

11:57 pm on Aug 6, 2009 (gmt 0)

10+ Year Member



Try adding some debugging statements to your code. One easy way is to echo the values of variables inside HTML comment tags (<!-- ... ->), then do a view page source.

[Or if you do a lot PHP programming, invest some time in implementing a good logging class, something that dumps debugging text to a file, and preferrably supports varying levels of debugging, e.g. 0=super-detail ... 100=major, that you can ajdust at run-time.]

Anyhow, i'd start off with dumping the contents of $_SERVER and $_REQUEST, and maybe $_GET:

echo "<!-- _SERVER=".htmlentities(var_export($_SERVER, true))."-->\n";
echo "<!-- _REQUEST=".htmlentities(var_export($_REQUEST, true))."-->\n";

And if they look ok, echo the contents of your ID variable after assignment, and your SQL statement before execution.

If i were to guess on the problem, i'd say either your <form> action attribute has dropped the ID, and/or the <form> is doing a POST and your ID lives in the $_POST global now. Double-check that with a view page source.

Hope this helps.

[edited by: eelixduppy at 12:33 am (utc) on Aug. 7, 2009]
[edit reason] disabled smileys [/edit]