antonyfal Posted September 3, 2011 Share Posted September 3, 2011 Hi, i got this code script im formulating. It supposed to run three applets in a row, only two of the three are working. The third applet calls to my chat script which i get working perfectly on an html file, but i would like to move it to my add_this_sharing.php file code to conserve space on my Page. So i have moved the code from an html file to a php file, i been at it on and off for 4 days now.. I get syntax errors, and when i get the page to open without syntax errors and everything seems fine in the source code, the chat app is not called and the error output is not shown.. IE: if there is a communication error between the call of the script and the execution of the script the div content will be displayed : "Loading...." - but that is not happening either.. // im guessing and have a good feeling that it is with the echo! that something is wrong, i have also tried every combanation of " " " &" ' " i could think of but not working.. here is my code: <?php //from here to $currenturl = $_SERVER['REQUEST_URI']; $newurl = explode("/", $currenturl); $url2 = $_SERVER['HTTP_HOST']; $thisfolder=$newurl[1]; $thisurl= 'http://'.$url2.'/'.$newurl[1].'/'; $myurls = 'http://'.$url2.'/'.$newurl[1].'/'.viewprofile.'/'.$profile_name.'/'.$profile_id.'.'.html; $thissite= 'http://'.$url2.'/'; echo '<table><tr><td valign="bottom" style="background-color:transparent; width:50%; height:23px; text-align:left;"> <!-- AddThis Button BEGIN --> <script type="text/javascript">addthis_pub = \'davidp13\';</script> <a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, \'\', \''.$myurls.'\', \'[TITLE]\')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="'.$thissite.'/js/share.png" width="125" height="33" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script> <!-- AddThis Button END --></td><td valign="bottom" style="background-color:transparent; width:50%; height:23px;text-align:right;"><div> <iframe scrolling="no" height="23px" frameborder="0" width="345px" src="'.$thisurl.'mailinglist/'.$profile_username.'/'.$profile_email2.'/index2.php"></iframe></div></td> <td> //here everything works <div> //from here down i cant get anything to run properly--- <!-- START PROFILECHAT CODE --> <div id="div_chatonline">Loading....</div> <script type="text/javascript"> var new_window = false; //(new window: true or false) var url_destination = \'http://www.domainname.com/'.$thisfolder.'/chat/'.$profile_username.'/'.$profile_email2.'/chat/\'; var url_adjuster = \'http://www.domainname.com/'.$thisfolder.'/chat/'.$profile_username.'/'.$profile_email2.'/chat/\'; var text_online = \'<a href="javascript:void(0);" onClick="dhtmlwindow.open(\''.$profile_username.boxes'\', \'div\', \''.$profile_username.'\', \''.$profile_contactperson.'\', \'width=224,height=237,left=200,top=150,resize=0,scrolling=0,center=1\'); return false"><img src="\'.$thisurl.\'chat/img/chat_is_open1.png" alt="CHAT ONLINE" width="89px" height="19px"></a>\'; document.write(\'<\' + \'script type="text/javascript" src="http://www.domainname.com/'.$thisfolder.'/chat/'.$profile_username.'/'.$profile_email2.'/chat/chat.js"></\' + \'script>\'); </script> <!-- END PROFILECHAT CODE --> </div> </td></tr></table>'; } function getRetVals() { return null; } } ?> Link to comment https://forums.phpfreaks.com/topic/246369-javascript-not-working-in-php-file/ Share on other sites More sharing options...
biggieuk Posted September 4, 2011 Share Posted September 4, 2011 Your line: $myurls = 'http://'.$url2.'/'.$newurl[1].'/'.viewprofile.'/'.$profile_name.'/'.$profile_id.'.'.html; is missing the <b>$</b> tag for viewprofile. Does that solve the issue? EDIT: also the string is formatted incorrectly, try this: $myurls = 'http://'.$url2.'/'.$newurl[1].'/'.$viewprofile.'/'.$profile_name.'/'.$profile_id.'.html'; Link to comment https://forums.phpfreaks.com/topic/246369-javascript-not-working-in-php-file/#findComment-1265297 Share on other sites More sharing options...
antonyfal Posted September 4, 2011 Author Share Posted September 4, 2011 Thaks for the reply: the "viewprofile" without the "$" also works but i did change it to a Variable, it is actually just a word in the url. My main problem is is with "echo" function. Im not familliar with it really. i use pat templates and the $output['whatever'] to html . . the piec of the puzzle above giving me hassle is this, to me now its just one big mess. i "\" and changed """ and "'" and ";" .. but i cant get it to echo and work... in the above code the fist is the ad_this_share that works the second code, the index2.php, calls to the users mailing list, that works too, just this bellow which is not outputting properly.. <div> <!-- START PROFILECHAT CODE --> <div id="div_chatonline">Loading....</div> <script type="text/javascript"> var new_window = false; //(new window: true or false) var url_destination = \'http://www.domainname.com/'.$thisfolder.'/globalchat/'.$profile_username.'/'.$profile_email2.'/chat/\'; var url_adjuster = \'http://www.domainname.com/'.$thisfolder.'/globalchat/'.$profile_username.'/'.$profile_email2.'/chat/\'; var text_online = \'<a href="javascript:void(0);" onClick="dhtmlwindow.open(\''.$profile_username.boxes'\', \'div\', \''.$profile_username.'\', \''.$profile_contactperson.'\', \'width=224,height=237,left=200,top=150,resize=0,scrolling=0,center=1\'); return false"><img src="\'.$thisurl.\'globalchat/img/chat_is_open1.png" alt="CHAT ONLINE" width="89px" height="19px"></a>\'; document.write(\'<\' + \'script type="text/javascript" src="http://www.domainname.com/'.$thisfolder.'/globalchat/'.$profile_username.'/'.$profile_email2.'/chat/chat.js"></\' + \'script>\'); </script> <!-- END PROFILECHAT CODE --> </div> </td></tr></table>'; Link to comment https://forums.phpfreaks.com/topic/246369-javascript-not-working-in-php-file/#findComment-1265308 Share on other sites More sharing options...
antonyfal Posted September 5, 2011 Author Share Posted September 5, 2011 OK!! i made tons of progress: i removed the <!-- START PROFILECHAT CODE --> and <!-- END PROFILECHAT CODE --> this indicated html --- i also remove the extra // removed this one <div> <div id="online"> and then changed all the ' to " on this line: var text_online = \'<a href="javascript:void(0);" onClick="dhtmlwindow.open("'.$profile_username.'box", "iframe", "http://www.google.com/", "'.$profile_name.'", "width=224px,height=237px,left=200px,top=150px,resize=0,scrolling=0,center=1");"><img src="http://www.mydomain.com/'.$thisfolder.'/globalchat/img/chat_is_open1.png"></a>\'; // im using the iframe as example with a google link... // the progress i made is: my online off line chat indicator works perfectly, the only problem im having now is the "onClick" its not working.. with single quotes i get erros, with double quotes i dont get errors, am i missing something on this line? //its a echo javascript in a php file.. to note: all links are as they should be, and all includes are all in place, i have also tried moving them all aswell, but it didnt work. Link to comment https://forums.phpfreaks.com/topic/246369-javascript-not-working-in-php-file/#findComment-1265628 Share on other sites More sharing options...
antonyfal Posted September 5, 2011 Author Share Posted September 5, 2011 solved it .. i wrote the final line like so: //basically un-comented all the double and single quotes.. and started with and ended with a double quote var text_online = "<a href=\"javascript:void(0);\" onClick=\"dhtmlwindow.open(\''.$profile_username.'box\', \'iframe\', \'http://www.google.com/\', \''.$profile_name.'\', \'width=224px,height=237px,left=200px,top=150px,resize=0,scrolling=0,center=1\');\"><img src=\"http://www.mydomain.com/'.$thisfolder.'/globalchat/img/chat_is_open1.png\"></a>"; Link to comment https://forums.phpfreaks.com/topic/246369-javascript-not-working-in-php-file/#findComment-1265670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.