[PHP] Works in html, not when echoed in PHP
Folks, Can't see an answer anywhere in the archives, so here goes. This works fine in plain html: When I put it in PHP thus: echo ""; When the page loads, I get an "Error: 'menuObj' is null or not an object" The onoff() function is what contains the menuObj, so I suspect the single quotes around the parameters mainmenu and on, but have tried everyway I can think of and can't get rid of the Error. The function is thus: function onoff (elemparent,elem,state) { if (loaded) { newstate = eval(elem+"_"+state); if (n4) { menuObj = eval (doc + elemparent + doc2 + elem); } else if (ie || n6) { menuObj = eval (doc + elem + doc2); } I would be grateful for any tips. Thanks, Aaron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Works in html, not when echoed in PHP
You are right, there is a reason I am echoing it in php, it is one result of an if statement. "; } else { echo ""; } ?> I tried echoing with single quotes - no change. So I compared the view source of the double quoted php generated page and of the html generated page - they are identical: So I no longer think php is parsing the javascript incorrectly - the same error happens if I put the 'onoff()' function directly in html and only put the 'start()' function in the if statement. The weird thing is that the php page still gives the error and the html does not. Anyway, I thought I would see if there were any more ideas as to what I am doing wrong. Thanks for the help, Aaron On 11/13/02 12:50 AM, "@ Edwin" <[EMAIL PROTECTED]> wrote: > echo ' onresize="window.location.reload(false)" topmargin="1" bottommargin="0" > leftmargin="0" rightmargin="0">'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Works in html, not when echoed in PHP
I'm not constructing it with, it is just included in the file. Does that clarify? Or did I misunderstand your point? On 11/13/02 1:47 AM, "Ernest E Vogelsinger" <[EMAIL PROTECTED]> wrote: > You didn't show how you construct the JavaScript string in PHP - I'm sure > the problem is with quoting in there. > > Have a look at your output in the browser (do a "View Source" or whatever > your Browser calls it), and check the JS your PHP application constructed. > You'll spot the error... > > At 05:28 13.11.2002, Aaron Merrick said: > [snip] >> Folks, >> >> Can't see an answer anywhere in the archives, so here goes. >> >> This works fine in plain html: >> >> > onresize="window.location.reload(false)" topmargin="1" bottommargin="0" >> leftmargin="0" rightmargin="0"> >> >> When I put it in PHP thus: >> >> echo "> onresize=\"window.location.reload(false)\" topmargin=\"1\" >> bottommargin=\"0\" leftmargin=\"0\" rightmargin=\"0\">"; >> >> When the page loads, I get an "Error: 'menuObj' is null or not an object" >> >> The onoff() function is what contains the menuObj, so I suspect the single >> quotes around the parameters mainmenu and on, but have tried everyway I can >> think of and can't get rid of the Error. >> >> The function is thus: >> >> function onoff (elemparent,elem,state) { >> if (loaded) { >> newstate = eval(elem+"_"+state); >> if (n4) { >> menuObj = eval (doc + elemparent + doc2 + elem); >> } >> else if (ie || n6) { >> menuObj = eval (doc + elem + doc2); >> } >> >> I would be grateful for any tips. >> >> Thanks, >> Aaron >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php > [snip] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] str_replace not replacing
I'm reading in to a variable $section1 an entire php file that creates a mysql table. I can output the variable in a new file just fine (figured out what all had to be escaped in the original file). My problem is, I want to replace the table name in the original file with a new table name before I output it to the new file. But the str_replace has no effect. Neither does an ereg_replace. Is there something in the content of the file that is foiling the replace? Here is what I have right now. It produces the same file content as is read in. The file I'm reading in is as follows: The table has been created."; } else { $msg = "echo mysql_error()"; } // reveal what happened echo "$msg"; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace not replacing
Richard, Thank you so much. That works perfectly. I knew it had to be something simple. Aaron > From: Richard Davey <[EMAIL PROTECTED]> > Reply-To: Richard Davey <[EMAIL PROTECTED]> > Date: Wed, 11 Feb 2004 15:04:44 +0000 > To: Aaron Merrick <[EMAIL PROTECTED]> > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] str_replace not replacing > > Hello Aaron, > > Wednesday, February 11, 2004, 3:00:47 PM, you wrote: > > AM> $section1 = file_get_contents("table_create.php"); > AM> str_replace($search, $replace, $section1); > > You need to assign the output of str_replace to something: > > $new_section = str_replace($search, $replace, $section1) > > -- > Best regards, > Richardmailto:[EMAIL PROTECTED] > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php