Jump to content

jacksonmj

Members
  • Posts

    54
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jacksonmj's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. $sql = mysql_query("INSERT INTO 'ae_system' VALUES ('".mysql_real_escape_string($line_array)."')") or trigger_error (mysql_error()); You are implicitly converting an array into a string here. This will always give the result "Array". (If a SQL query is failing, try printing the query and having a look to see if anything obvious is wrong with it). Perhaps you need an implode()? ...mysql_real_escape_string(implode("','",$line_array))...
  2. Sorry, should have used $matches[1]. The regexp also needed slight modification, and I've added code to leave hrefs ending in .html intact. function link_replace_callback($matches) { if (substr($matches[1],-5)==".html") return 'href="'.$matches[1].'"'; $linkUrl = str_replace(" ","-",strtolower($matches[1])); return 'href="'.$linkUrl.'.html"'; } echo preg_replace_callback('~href="([^"]+)"~',"link_replace_callback",$WebPage); (I've actually tested my code this time!)
  3. Use the scrollIntoView method to go to the element when an anchor link is clicked. For example: <script type="text/javascript"> function anchorLink(anchorLinkElement) { document.getElementById(anchorLinkElement.hash.substr(1)).scrollIntoView(1); return false; } </script> <a href="#test" onclick="return anchorLink(this)">Test</a>
  4. setInterval is better than setTimeout for repeated execution of a function at regular intervals. In this case: setInterval(myfunction,3000);
  5. The info I gave was straight from the PHP manual entry for session_register. As far as I can gather from the manual: $_SESSION was preferred since 4.1.0 (when $_SESSION was introduced). session_register disabled by default since 4.2 (due to register_globals turned off by default, like you say) session_register deprecated since 5.3.0 session_register removed in 6.0.0 Disabled by default is not necessarily the same as deprecated... However, I must admit that you are quite right to criticise me - session_register has been the wrong way to do sessions for much longer than I implied in my original post.
  6. Spend a couple of minutes reading the PHP manual. http://www.php.net/manual/en/language.oop5.interfaces.php If you're still unable to solve your problem, post the relevant code.
  7. You need to specify the destination filename as well as the directory. copy("/home/simwsim/public_html/protect/$file", "/home/simwsim/public_html/submitted/".$random."/".$file)
  8. session_register is deprecated as of PHP 5.3.0 and removed as of PHP 6.0.0. $_SESSION['username'] = $name; is all you need to do to store something in $_SESSION. Session data is stored on the server, and the session id identifies which set of session data belongs to that visitor. So there is no way, unless your code specifically allows it, for visitors to edit session data. They might be able to use someone else's session, but they can't edit the actual session data. However, it is good practice to escape all data that goes into a SQL query, regardless of whether you think the data is safe or not. Regarding mysql_close, read the PHP manual - you are correct.
  9. $zipFileName = substr($realFileName,strpos($realFileName,"protect")+7); Change the +7 above to +8
  10. bool ZipArchive::addFile ( string $filename [, string $localname ] ) Adds a file to a ZIP archive from a given path Parameters filename - The path to the file to add. localname - local name inside ZIP archive. So replace $zip->addFile(.....) with the following, which will remove everything up to and including the first instance of "protect" in the zip file paths. $realFileName = realpath($key); $zipFileName = substr($realFileName,strpos($realFileName,"protect")+7); $zip->addFile($realFileName,$zipFileName) or die ("ERROR: Could not add file: $key"); This will let you solve both problems.
  11. Might the following work? foreach($parents as $parent) { if (!$xml->$parent || ($xml->$parent == '') ) continue; foreach($xml->$parent->children() as $name => $node) {
  12. Use preg_replace_callback. For example: function link_replace_callback($matches) { $linkUrl = str_replace(" ","-",strtolower($matches[0])); return 'href="'.$linkUrl.'"'; } echo preg_replace_callback( '~href="([^"])+"~', "link_replace_callback", $WebPage); You could probably also use the callback function to leave intact anything with .html in it.
  13. onclick="showUser(document.getElementById('id').value)"
  14. By "external", do you mean that it is on a different domain or subdomain? Perhaps post the relevant code?
  15. Your main problem is that you have not created the XMLHttpRequest object. Add something like this to your code: if (window.XMLHttpRequest) { var ajaxRequest = new XMLHttpRequest(); } else if (window.ActiveXObject){ var ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } Also, both open() and send() must be called before the request is sent to the server. readyState will only be equal to 4 after the request has been successfully sent to the server (i.e. after calling both open() and send()) and a response retrieved. Replace: ajaxRequest.open("POST", "serverTime.php", true); if(ajaxRequest.readyState == 4){ ajaxRequest.send("test=hi"); } with: ajaxRequest.open("POST", "serverTime.php", true); ajaxRequest.send("test=hi"); if(ajaxRequest.readyState == 4){ alert(ajaxRequest.responseText); //Do something with the response }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.