Those errors wont occur when you remove the "echo" / "print_r" statements ... they are just moaning about the web server detecting content and expressing its own headers...
If you remove the lines i asked u to add it will be fine Alex ----- Original Message ----- From: "WLQ" <[email protected]> To: "Prototype & script.aculo.us" <[email protected]> Sent: Friday, July 03, 2009 1:53 PM Subject: [Proto-Scripty] Re: MySQL - order ID > > Well the first one returned the dropped item details: > widgets Object ( [id] => 3 [name] => 3.00 [description] => 3 > [position] => 3 [updated_at] => 2009-06-05 14:39:07 ) > > And the second one ($original) returned an id of 3. So the answer is > you should write $master instead of $original. > > So this problem is solved, but the errors won't stop. You solve one > problem and here you go another one: > Cannot modify header information - headers already sent by (output > started at:1) LOCATION: line 8 > > >> If anything it should be $master as thats what is most likely to be an >> array.... I dont know MAR at all but unless it parses the input into a >> loop >> then t is inal is moe likely to be an id/string/int thaMAR array... > >> >> To test >> > er............ { >> >> print_r($master); // shto d return array >> >> eay >>"<hr />".$original); // should return id/int/string (not an array or >> object) >> >> ----- Original Message ----- >> From: "WLQ" <[email protected]> >> To: "Prototype & script.aculo.us" >> <[email protected]> >> Sent: Friday, July 03, 2009 12:51 PM >> Subject: [Proto-Scripty] Re: MySQL - order ID > orde > ID >> > d it then be: >> $data = get_object_vars($master); >> >> Instead of: >> $data = get_object_var ordei ID >> > >> >> > Read through the s the and third lines slowly and carefully. Look at >> > each variable that is being set and each variable that is being read. >> > (Variables to the left of the = are being set.) Ask yourself what it's >> > supposed to be carrying, and see if you can spot what it really is >> > instead. >> >> > Here's a hint: In line two, I assigned a value to a variable, but on >> > line 3, I forgot to use it and used something else instead. >> >> > Walter >> >> > On Jul 2, 2009, at 6:09 AM, WLQ wrote: >> >> > > This is as far as I've been able to go, please tell what's wrong. >> >> > > $original = $_POST['original']; >> > > if($master = MyActiveRecord::FindById('widgets',$original)){ >> > > $dat> $data = get__vject_varginal); >> > > if ( is_array($data) ) >> > > array_shift($data); >> > > $new = MyA> > $data = gereobject_vnes',$data); >> > > $new->save(); >> (); if(false ==lse === $ntw->gors()){ >> > > header('Content-type: text/html; charset=utf-8'); >> > > //tve(); >> > > ift you need: >> > > print 'rint 'i.em_ew->id; >> > > }else{ >> > > he> >r('HTTP/1.0 500 Server Error',true,500); >> > > exit; >> > > } > print itese{ >> >> > > header('HTTP/1.0 404 Missing',true,404); >> >> > > } >> >> >> >>You're solving the wrong problem, then. Keep looking, it's right >> > >> there >> > >> in front of you. >> >> > >> Walter >> >> > >> On Jul 1, 2009, at 1:36 PM, WLQ wrote: >> >> > >>> I understand I should put this: >> > >>> if(is_array($data)) { >> > >>> array_shift($data); >> > >>> } >> >> > >>> Instead of: >> > >>> array_shift($data); >> >> > >>>> Or just do .... >> >> > >>>> if(is_array($data)) { >> > >>>> array_shift($data); >> >> > >>>> } >> >> > >>>> HTH Alex >> >> > >>>> ----- Original Message ----- >> > >>>> From: "Walter Lee Davis" <[email protected]> >> > >>>> To: <[email protected]> >> > >>>> Sent: Wednesday, July 01, 2009 5:56 PM >> > >>>> Subject: [Proto-Scripty] Re: MySQL - order ID >> >> > >>>>> Which means it's not getting an array. So look and see whate whaS > it IS >>>> getting. What is the value of $data at that point? (Use echo(), >> > >>>>> print_r(), see that it ke that to output the value.) >> >> > >>>>> I can see the error right away, looking back over the code. It's >> > >>>>> a >>s >>>>> fairly stupid error on my part introduced while refactoring the >> > >>>>> working code into an example you could pick apart and learn from. >> >> > >>>>> I want you to find it, because otherwise you will never stand on >> > >>>>> your >> > >>>>> own here. >> >> > >>>>> Walter >> >> > >>>>> On Jul 1, 2009, at 10:31 AM, WLQ wrote: >> >> > >>>>>> But here's what I get in error: >> > >>>>>> array_shift() [function.array-shift]: The argument should be an >> > >>>>>> array >> >> > >>>>>> On this line: >> > >>>>>> array_shift($data); >> >> > >>>>>>> Yes. Like any example that you will ever find on the Web, this >> > >>>>>>> one >> > >>>>>>> needs to be adjusted to match your environment. Some basic >> > >>>>>>> fluency in >> > >>>>>>> PHP is a requirement to use the MAR system, it can't divine >> > >>>>>>> everything >> > >>>>>>> for you. >> >> > >>>>>>> Walter >> >> > >>>>>>> On Jul 1, 2009, at 5:57 AM, WLQ wrote: >> >> > >>>>>>>> Right, shouldn't then that be 'widgets'? Because the table of >> > >>>>>>>> our >> > >>>>>>>> original sortable list were controlled by the widgets table. >> > >>>>>>>> So >> > >>>>>>>> like: >> > >>>>>>>> if($master = MyActiveRecord::FindById('widgets',$original)){ >> >> > >>>>>>>>> Originals is a table in the database, it contains one of each >> > >>>>>>>>> type of > pe of >> > >>>> >>> thinu wish to be able to clone into the clones table. >> > >>>>>>>>> MyActiveRecord type of >> > >cl>>>>>> teach table you "wrap" >> > >>>>>>>>> it >> > >>>>>>>>> around, and each row of the table becomes an object of that > hat >> > >>>>>>class >> > >>>>>>>>> when >> > >>>>>>>>> you request it through MAR. >> >> > >>>>>>>>> In shf that >> > >>>: >> >> > >>>>>>>>> if($master = >> > >>>>>>>>> MyActiveRecord::FindById('originals',$original)){ >> >> > >>>>>>>>> ...if it finds a table called 'originals' in inr database, >> > >>>>>>>>> will >> > >>>>>>>>> ret return the rothwith thematching $original (or false). >> >> > >>>>>>>>> Walter >> >> > >>>>>>>>> On Ju>>>>> return t 1 row wit WLQ wrote: >> >> > >>>>>>>>>> It says - Class originals does not exist >> > >>>>>>>>>> Where does the originals class comes from? What is the >> > > >>>>>>>> originals >> > >>>>>>>>>> from >> > >>>>>>>>>> the code above? >> >> > >>>>>>>>>>> If this is the code you are using (and I've added the >> > >>>>>>>>>>> missing >> > >>>>>>>>>>> close >> > >>>>>>>>>>> parenthesis), then the fact that you are getting a 200 back >> > >>>>>>>>>>> (and a >> > >>>>>>>>>>> new >> > >>>>>>>>>>> ID) means that you have successfully created a new clone. >> > >>>>>>>>>>> Otherwise, >> > >>>>>>>>>>> you should be getting a 500 or 404 back. >> >> > >>>>>>>>>>> //create_clone.php >> > >>>>>>>>>>> $original = $_POST['original']; >> > >>>>>>>>>>> if($master = MyActiveRecord::FindById('originals', >> > >>>>>>>>>>> $original)){ >> > >>>>>>>>>>> $data = get_object_vars($rs(ginal); >> > >>>>>>>>>>> array_shift($data); //get rid of the ID >> > >>>>>>>>>>> >>> $new = MyAeRiveRecctreate('clones',$data); >> > >>>>>>>>>>> $new->save(); >> > >>>>>>>>>>> if(false>>>>>>>> $new _eMyActive{ >> > >>>>>>>>>>> header('Content-type: text/html; >> > >>>>>>>>>>> charset=utt=utf-8'); >> > >>>>>>>>> //this is the part you need: >> > >>>>>>>>>>> print 'item_' . $new->id; >> > >>>harset=ut=utf-8'){ >> >>>>>>>>>>> header('HTTP/1.0 500 Server Error',true, >> > >>>>>>>>>>>>> 50; > ); >> >>>>>>>>>>> exit; >> > >>>>>>>>>>> }}else{ >> >> > >>>>>>>>>>> header('HTTP/1.0 404 Missing'>>>>>>>0> 5 >> > > > >> > >>>>>>>>>>> } >> > with the Console tab >> > >>>>>>>>>>> of >> > >>>>>>>>>>> Firebug >> > >>>>>>>>>>> open. Make sure Firebug is set to show XHR transactions. >> > >>>>>>>>>>> You >> > >>>>>>>>>>> should >> > >>>>>>>>>>> be >> > >>>>>>>>>>> able to observe the request to create_clone, a>> ablethe >> > >>>>>>>>>>> reply >> > >>>>>>>>>>> from >> >>>>>>>>>>>>> the server. The reply should be the new ID of your clone. >> >>>>>>>>>>>>> If >> > >>>>>>>>>>> it >> > >>>>>>>>>>> isn't, >> > >>>>>>>>>>> then you have more debugging to do. >> >> > >>>>>>>>>>> Things to check here: >> >> > >>>>>>>>>>> * Have you included/required the library (MyActiveRecord) >> > >>>>>>>>>>> in >> > >>>>>>>>>>> this >> > >>>>>>>>>>> script, and have you defined the constants it needs (MySQL >> > >>>>>>>>>>> address >> > >>>>>>>>>>> and >> > >>>>>>>>>>> credentials, also known as a DSN). >> > >>>>>>>>>>> * Have you got a MySQL table called clones? >> >> * Have you g Have you enabled error reporting on your >>>>>> * Have r >> > >>>>>>>>>>> test >> > >>>>>>>>>>> pages, >> > >>>>>>>>>>> so you can see the PHP errors as they whiz by? >> > >>>>>>>>>>> * Have you ordered that fat book I recommended? >> >> > >>>>>>>>>>> Debugging PHP is like playing Whack-a-Mole. You fix one >> > >>>>>>>>>>> thing, >> > >>>>>>>>>>> and >> > >>>>>>>>>>> another pops up. You iterate, in other, more dainty words. >> >> > >>>>>>>>>>> Walter >> >> > >>>>>>>>>>> On Jun 28, 2009, at 12:04 PM, WLQ wrote: >> >> > >>>>>>>>>>>> Also I've used that clone.php you gave, the only thing it >> > >>>>>>>>>>>> doesn't do >> > >>>>>>>>>>>> is change the MySQL table itself. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---
