Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by dcole.ath.cx

  1. I can't find a lot of info on the web about the pros and cons of using popen to help speed up a process. There are cases where somethings just have to be done one right after the other, but other things, such as web pages are often modular. Would web programs, such as CMS and Forums be faster if they used multiple popen functions to process different information at the same time? These programs often have very modular code and it seams like a page could be processed faster with the use of multiple processes. Or is there going to be very little improvement or slowing down by trying to have parallel processes in these kind of web programs? How much data crunching needs to be done to make it worth having more than one pipe?
  2. This is an easy fix. You give both floating divs borders on their touching sides. That is, if the left one is longer it well create the border all the way down and vise versa. The only problem you may run into is having the two borders not positioned on top of one another. Which just means you need to adjust the divs dimensions.
  3. It would be easier to find the problem if you create the page online. Myself, along with a large group of web developers use Firefox's Firebug to correct CSS mistakes.If you don't want to post it online or would like to do it your self, I would recommend getting the Firebug plugin.I would guess that the problem would be with the div tag that makes up the nav, but I don't know how the html is set up and it's hard to track what is the parent of the section that uses #nav.If I was you I would wrap a div tag around the nav and have it create the black background and white top/bottom border. This new div would have a width of 100%. With nav I would set margins to the widths of your "white spaces". This would align the nav in the middle. I would the set the "ul" that makes up the nav list to have an auto margin to center the nav items.text-align: center will ONLY align TEXT, not HTML elements.
  4. If your only going to set the background color, then the best bet would be to use "background-color" tag instead of "background".When I use the "background" tag I always define everything, such as "background: #CCC none repeat scroll 0%;"You can get more information at http://www.w3schools.com/css/css_background.asp
  5. Well I got the preg match to work. It turns out I was look at the wrong source code, I wanted to read XML... so my patterns is: @(<link>.{5,150}</link>)@isx and it works for what I'm doing.
  6. Thank, so I want to pull out URLs that have more that the domain name, something such as:try"><h3><a href="http://sub.example.com/~d/Folder/~3/123456789/">Example...There may not be white space before <a href..., it may have a subdomain, may have many folders that could contain any acceptable URL char.I'm currently messing around with something such as: preg_match('%(<h3><a href="http)(.*?)(">)%is', $line, $matches);My thoughts behind it were: begins with <h3><a href="http, then has *anything*, the ends with ">What should the match phrase look like?
  7. I'm working on a crawler like script. It first opens a page and puts the source code into a variable. I want to pick out the URLs that have <h3><a href=" in front of them and put them into a list. Is their a way to pick the information out of the variable without having to break it up and sift through it? Or what would be the best way for me to do this?Example: example = "<h1>hi</h1><h3><a href="http://example.com">Example Site</a></h3> blah blah blah";link = "http://example.com"; Maybe the best way would to use strpos() and find the beginning and end of the URL, then use substr to get the URL.
  8. I am now the happiest person in the world! :) That code did the trick, but I did change how it added data to tempdata like Justsomeguy suggested.THANKS Synook and Justsomeguy!
  9. So alert("Hello"); does work, but alert(xmlHttp.resonseText); does not. The server.php file is also a plain text file now.The code that calls updateMsgOnBrowser is the following code and it uses XML, should I change it or is there another way of getting the text test from server.php without xmlHttp.responseText? function talktoServer(){ var req = newXMLHttpRequest(); //register the callback handler function var callbackHandler = getReadyStateHandler(req, updateMsgOnBrowser); req.onreadystatechange = callbackHandler; req.open("POST", "server.php", true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); //get the value from the text input element and send it to server var testmsg = document.getElementById("testmsg"); var msg_value = testmsg.value; req.send("msg="+msg_value);}
  10. maybe xmlHttp.responsetext isn't defined, but then what would it be?... Here is everything elseThe PHP code below writes the JSON XML and encodes it. $retval = array('timestamp' => $ts, 'messages' => $tempmessages);include "json.php";$json = new Services_JSON();echo $json->encode($retval); And here is the XML out put, although to get this the PHP file couldn't get the POST data... XML Parsing Error: not well-formedLocation: .../server.phpLine Number 1, Column 1:{"timestamp":1201453071,"messages":["Bot: My responses are limited.","User: ","Bot: hey","User: hi","Bot: hi","User: hi","Bot: hi","User: hi","Bot: hey","User: hi"]}^ That ^ above goes to the {, BTW
  11. I was trying to import XML but it wasn't working and now I'm using JSON... Below is the code that isn't working. What are the errors in the code? The JSON is printing a variable called timestamp and an array called messages. var lastPing = 0;function updateMsgOnBrowser(testXML) { eval("var retval = " + xmlHttp.responseText); var timestamp = retval.timestamp; if (timestamp > lastPing) { lastPing = timestamp; var msg_display = document.getElementById("msg_display"); for (var i = 0; i < retval.messages.length; i++) { var tempdata = tempdata + "<br />" + retval.messages[i]; } msg_display.innerHTML = tempdata; }}
  12. Here is what my javascript looks like when it outputs a single line to the screen. My server.php has the JSON stuff on it now and is outputting the correct information, but I can't write the javascript code so it works correctly. Within updateMsgOnBrowser is the variable msg_display.innerHTML and this has to have the retval.messages in it, but I can't get it to function correctly. The following is the old javascript without the eval code: function whichButton(event){ if(event.keyCode == 13){ talktoServer(); }}function talktoServer(){ var req = newXMLHttpRequest(); //register the callback handler function var callbackHandler = getReadyStateHandler(req, updateMsgOnBrowser); req.onreadystatechange = callbackHandler; req.open("POST", "server.php", true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); //get the value from the text input element and send it to server var testmsg = document.getElementById("testmsg"); var msg_value = testmsg.value; req.send("msg="+msg_value);}// This is the callback functions that gets called// for the response from the server with the XML datavar lastPing = 0;function updateMsgOnBrowser(testXML) { var test = testXML.getElementsByTagName("test")[0]; var message = testXML.getElementsByTagName("message")[0]; var ip = testXML.getElementsByTagName("ip")[0]; var timestamp = test.getAttribute("timestamp"); if (timestamp > lastPing) { lastPing = timestamp; var ip_value = ip.firstChild.nodeValue; var message_value = message.firstChild.nodeValue; var msg_display = document.getElementById("msg_display"); msg_display.innerHTML = " Server got the message: \"" + message_value + "\"" + "<br>Server IP: "+ ip_value + " Server Timestamp: \""+ timestamp + "\""; }}//the following two functions are helper infrastructure to //craete a XMLHTTPRequest and register a listner callback functionfunction newXMLHttpRequest() { var xmlreq = false; if (window.XMLHttpRequest) { xmlreq = new XMLHttpRequest(); } else if (window.ActiveXObject) { // Try ActiveX try { xmlreq = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e1) { // first method failed try { xmlreq = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e2) { // both methods failed } } } return xmlreq;} function getReadyStateHandler(req, responseXmlHandler) { return function () { if (req.readyState == 4) { if (req.status == 200) { responseXmlHandler(req.responseXML); } else { var hellomsg = document.getElementById("hellomsg"); hellomsg.innerHTML = "ERROR: "+ req.status; } } }}
  13. I tried that, but it only wants to take one line or some...
  14. I'm not the best a JavaScript. I'm trying to XML message from a PHP script that looks like <test timestamp=$ts><message1>hi</message1><message2>Hey</message2>...</test>. The message number is variable in quantity and given by var messagenumber.Can someone look through my code and tell me what's wrong. I think one of the errors in how I use final_value when defining the new final_value value. var lastPing = 0;function updateMsgOnBrowser(testXML) { var test = testXML.getElementsByTagName("test")[0]; var size = testXML.getElementsByTagName("size")[0]; var timestamp = test.getAttribute("timestamp"); if (timestamp > lastPing) { lastPing = timestamp; var size_value = size.firstChild.nodeValue; for (i=0; i<=size_value; i++){ var messagename = "message" + i; var message = testXML.getElementsByTagName(messagename)[0]; var message_value = message.firstChild.nodeValue; if(i == 0){ var final_value = message_value; } else{ var final_value = final_value + "<br />" + message_value; } } var msg_display = document.getElementById("msg_display"); msg_display.innerHTML = "<p>" +final_value + "</p>"; }} If this doesn't look good, what would be a better way to get all the variables from a MySQL Databank and print them on a page, but keep updating it without reloading the page by using AJAX.
  15. This doesn't account for Silverlight taking over web apps, but Flash...Well if Flash had an "accident" and "magically" didn't work in the next version of IE or any following version of IE, then Silverlight would have to take over Flash's place. Note: Microsoft would not block flash because that would be illegal... it would just happen "magically" or through an act of God. To add to this, new comers to web development often go through a stage of loving Flash and Microsoft could tap into this and create a generation of Silverlight users.A more likely case however would be added security to protect against "Flash viruses"... but the security would be so annoying Silverlight would have to be used in exchange.
  16. I've done some messing around and it is due to a return character.... but I can't get rid of it with trim! I've tried using \n and a real return, but nothing happen, it's still there. I've also tried rtrim...
  17. That problem is now worked out... I had a variable that would sometimes be blank and you can't do that with MySQL, so I added an if statement.Now I have a new problem. I have the above code in a FOR loop, as you can tell by the $g variable. But when it writes to the database only the last INSERT has the right string added to the Database, everyone before that is just blank (Not NULL). When I print mysql_query for each INSERT it does have the correct string ready to be inputted. What could be causing this? There are no PHP or MySQL errors.
  18. Maybe your browser doesn't support it. I went and tried some DHTML examples that w3school provided and they didn't work in IE7.
  19. Does it have inverse sin and inverse cos? tan = sin/cos and the same goes for inverse trig functions, so tan^-1 = (sin^-1) / (cos^-1)Other wise, remember that inverse tan is just tan with the X and Y switched.arctangent:y = arctan(x)x = tan(y) Domain: allRange:pi/2 < y < pi/2If that all fails, you could use a chart... If X = "this", then Y = "that"
  20. Below is a script that only does the "die" and prints "Error, insert query failed". What could be the cause of this? Did I setup the $query line correctly? I've messed with the single quotes in VALUES, but it didn't seem to be the problem. There is not PHP error. They MySQL DB is working correctly and was tested with another script. Thanks.
  21. Can i get some help with this error, thanks. What is the problem? Is it that $result is giving it bad data or what?[error] PHP Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /var/www/file1.php on line 131, referer: http://example.com/file2.html126 // find input from MySQL127 $query = 'SELECT response, preceed FROM $assignedtable';128 $result = mysql_query($query);129 // gonecount counts the line were on in the MySQL DB130 $gonecount = 0;131 while(list($response,$preceed)= mysql_fetch_row($result)) {132 for($g=0; $g<$gonesize; $g++){133 if ($response == $gone[$g]) {134 $isgone[$g] = 1;135 $locgone[$g] = $gonecount;136 }137 }138 $gonecount++;139 }
  22. If I have something like this: $query = 'SELECT message, response FROM $groupsconvert[$o]';$result = mysql_query($query); How can I count how many rows I have? I'm trying to pick a value of a random row. I really don't want to use a while loop and count it. I think I could use: $countresult = count(mysql_fetch_row($result)); But will that could just the current string or is that going to count the number of rows in result?
  23. When I have things like +, =, and ' in the data I insert into my MySQL Data Base Table it doesn't work. How can I fix this?If this isn't a problem for MySQL, it could be some where when I'm extracting the data. PHP fetches the data in the database, then sends it through AJAX to the browser.Thanks.
  24. Oops... that is the problem. The code works now, Thanks.
  • Create New...