squiblo
Members-
Posts
483 -
Joined
-
Last visited
-
Days Won
2
Everything posted by squiblo
-
I've Googled but cannot find anything, I'm sure it is out there but I'm looking in the wrong places. Lets say I have.. $string = "visit my website www.domain.com"; How can I put the url into a variable like.. $url = "www.domain.com"; and come up with something like.. $new_string = "visit my website <a href='http://" .$url. "'>" .$url. "</a>"; Thanks
-
I have a file (file.txt) and text is always being appended, how can I get last line only from the file. Thanks
-
thats done the trick, thanks
-
when I append more text to the content of the file it does not go onto a new line in the file, the directory to the file does work as text is appending, but not properly. $message1 = $_POST['message']; $message1 = "<li>". $message1 . "</li>"; $file1 = fopen($lang_folder.$chat_file, 'a') or die("can't open file"); fwrite($file1, "<b>" .$username. " (" .date('G:ia'). ") says:</b><br>" .$message1. "\n"); fclose($file1);
-
file.txt test.php the following puts each line of the file into an array read('file.txt'); How can I show the content of file.txt without using the function readfile() and without showing it as an array. Thanks
-
As PHP gets updated every now and again, where are some of the top resources to read about these and understand what is being updated and why, and maybe what will come in the future. Thanks
-
the following does not work $old = "*(#01)*"; $new = "\"; $message = str_replace($old, $new, $message); thanks
-
Thank you salathe, that has worked perfect, i also have another small problem, the following does not work var message1 = message1.replace(/+/g, replace5_1);
-
The first parameter in the replace function is incorrect but I do not know the right way of putting it. var replace4_1 = "*(#92)*"; // \ var message1 = message1.replace(/\/g, replace4_1); Thanks
-
I still cant figure this one out :-\
-
Lets say i have a textarea like this... <textarea name='textarea'>content</textarea> I want the scroll of the textarea to load showing the bottom of the content when the page loads how can this be done?
-
I have a Javascript file named 'javascript.js' when i put 'script 1' inside it (without script 2) it works perfectly but when i put them both of the scripts in together, 'script 2' does not work while 'script 1' still works. Script 1 //chat 1 input var http_request1 = false; function makePOSTRequest1(url, parameters) { http_request1 = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request1 = new XMLHttpRequest(); if (http_request1.overrideMimeType) { // set type accordingly to anticipated content type //http_request1.overrideMimeType('text/xml'); http_request1.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request1 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request1) { alert('Cannot create XMLHTTP instance'); return false; } http_request1.onreadystatechange = alertContents1; http_request1.open('POST', url, true); http_request1.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request1.setRequestHeader("Content-length", parameters.length); http_request1.setRequestHeader("Connection", "close"); http_request1.send(parameters); } function alertContents1() { if (http_request1.readyState == 4) { if (http_request1.status == 200) { //alert(http_request1.responseText); result1 = http_request1.responseText; document.getElementById('myspan').innerHTML = result1; } else { alert('There was a problem with the request.'); } } } function get1(obj) { var poststr1 = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value ); var replaceAND1= "and38"; var message1 = poststr1.replace(/&/g, replaceAND1); document.getElementById("mytextarea1").value = ''; makePOSTRequest1('http://localhost/includes/chat/textarea_input/sql1.php', message1); } Script 2 var http_request2 = false; function makePOSTRequest2(url, parameters) { http_request2 = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request2 = new XMLHttpRequest(); if (http_request2.overrideMimeType) { // set type accordingly to anticipated content type //http_request2.overrideMimeType('text/xml'); http_request2.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request2 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request2 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request2) { alert('Cannot create XMLHTTP instance'); return false; } http_request2.onreadystatechange = alertContents2; http_request2.open('POST', url, true); http_request2.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request2.setRequestHeader("Content-length", parameters.length); http_request2.setRequestHeader("Connection", "close"); http_request2.send(parameters); } function alertContents2() { if (http_request2.readyState == 4) { if (http_request2.status == 200) { //alert(http_request2.responseText); result2 = http_request2.responseText; document.getElementById('myspan').innerHTML = result2; } else { alert('There was a problem with the request.'); } } } function get2(obj) { var poststr2 = "mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value ); var replaceAND2= "and38"; var message2 = poststr2.replace(/&/g, replaceAND2); document.getElementById("mytextarea2").value = ''; makePOSTRequest2('http://localhost/includes/chat/textarea_input/sql2.php', message2); }
-
the following code only seems to replace the first "&" but any "&"s after that are not changed for example.... if var poststr = my name is bob & i live in england (this works) but... if var poststr= my name is bob & i live in england & i like pizza (this does not work) var replaceAND = "and38"; var message = poststr.replace("&", replaceAND); alert(message);
-
I am trying to post data to another page (i am trying to make my own shoutbox/chat sort of thing) without refreshing the page, I have done some research and found a few scripts and tried to mix them together and I have come up with the following shown below, my problem is that the data does not even send. ajax.js var xmlhttp; function showUser() { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var content = "bghkefgrgy"; xmlhttp.open("POST","http://localhost/test/response.php", true); xmlhttp.setRequestHeader("content-type","application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("content-length", content.length); xmlhttp.setRequestHeader("connection","close"); xmlhttp.send(content); } function stateChanged() { if (xmlhttp.readyState==4) { document.getElementById("response").innerHTML=xmlhttp.responseText; } } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } index.php <html> <head> <script type="text/javascript" src="http://localhost/test/ajax.js"></script> </head> <body> <form> <input type='button' value='send' onclick="showUser();"> </form> <div id='response'></div> </body> </html> response.php <?php print_r($_SERVER); ?>
-
that has worked perfectly thanks
-
How would I do that, javascript isn't one on my strong points :-\ thanks for the reply
-
when i only have this on the page...it works perfectly <script> var xmlhttp; function chat1() { showUser1(); } function showUser1(str) { xmlhttp=GetXmlHttpObject1(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var url1="http://localhost/includes/chat/chat_output/sql_output/sql1.php"; url1=url1+"?q="+str; url1=url1+"&sid="+Math.random(); xmlhttp.onreadystatechange=stateChanged1; xmlhttp.open("GET",url1,true); xmlhttp.send(null); } function stateChanged1() { if (xmlhttp.readyState==4) { document.getElementById("chatoneoutput").innerHTML=xmlhttp.responseText; showUser1(); } } function GetXmlHttpObject1() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } </script> <div id="chatoneoutput"><b></b></div> the only problem is that i also want this on the page <script> var xmlhttp; function chat2() { showUser2(); } function showUser2(str) { xmlhttp=GetXmlHttpObject2(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var url2="http://localhost/includes/chat/chat_output/sql_output/sql2.php"; url2=url2+"?q="+str; url2=url2+"&sid="+Math.random(); xmlhttp.onreadystatechange=stateChanged2; xmlhttp.open("GET",url2,true); xmlhttp.send(null); } function stateChanged2() { if (xmlhttp.readyState==4) { document.getElementById("chattwooutput").innerHTML=xmlhttp.responseText; showUser2(); } } function GetXmlHttpObject2() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } </script> <div id="chattwooutput"><b></b></div> You will notice they are nearly the same but different. When I add the second one, the 1st one stops working (nothing is shown) but then the 2nd one works perfectly, how can i make them both work properly without them effecting one another.. thanks
-
It seems so simple (probably is) but I cant find what is wrong
-
I have a page called 'change_language.php' and all that is in the page is this.... $lang = $_GET['lang']; setcookie('language',$lang,time()+86400); if (isset($_COOKIE['language'])) header('location: http://localhost/'); the page does redirect suggesting that the cookie has been set because of the if statement, but when I get to the redirected page I test if the cookie has been set by putting... echo $_COOKIE['language']; and nothing is echoed suggesting the cookie has not been set.
-
I am trying to make the following if statement more convenient for myself so I don't have to write it out all the time, to do this I am trying to put it into a function... ((isset($_SESSION['activated']))||(isset($_COOKIE['activated']))) and here is my attempt at putting it into a function but I am clearly doing something wrong... function loggedin() { if ((isset($_SESSION['activated']))||(isset($_COOKIE['activated']))) } Please help
-
Soon I am going to get started on something I've wanted to do for a long time, I want a user to be able to broadcast themselves (video and audio) and other users able to watch or listen to them (just like TV and radio) as live as possible, users watching will be able to pause, rewind and fast forward the broadcast. Right now I'm a just concentrating on the "TV" aspect. Is it possible using PHP for the user to upload the broadcast at the same speed a user can download and watch the broadcast? If so how can this be done? (a few key words and ill be on Google doing the research). Or the other option is to stream the video but the problem I can think of here is that the user will not be able to rewind or fast forward the broadcast as it is not being stored anywhere (well this is what I think, I'm not sure). What do you think is the best way of doing something like this? What languages would you use? Have you done anything like this before? If so, how? Do you know any guides related to this? Will I NEED a flash media server? Are there any other options? Thanks.
-
I have been searching for many hours now, I'm getting slower closer every minute, I have come across something called Red5 (an open source flash server) but now I seem to have come to a stand-still. If you know anything at all please help. Thanks.
-
I am trying to set up a website where a user can stream his/her video and audio live to all other users watching. I want to do this by using flash (or any other recommended) but need to be pointed in the right direction to know how and where to start. I do not want any communication between the broadcasting user and the viewing user, so it will be like watching TV. Please help, if you know of any guides, tutorials or little pieces of information let me know, every bit of information will help me a lot. Thanks
-
this doesnt work.. $option = "<span id='foo' onclick=\"Delay('foo');\">Add as friend</span>"; and niether does this $option = "<span id='foo' onclick='Delay('foo')'>Add as friend</span>"; any other options?
-
Please help anyone, I've been at this little thing for hours