
jacksonmj
Members-
Posts
54 -
Joined
-
Last visited
Never
Everything posted by jacksonmj
-
$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))...
-
I need help with converting HREF link to lowercase and dashes
jacksonmj replied to belick's topic in Javascript Help
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!) -
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>
-
setInterval is better than setTimeout for repeated execution of a function at regular intervals. In this case: setInterval(myfunction,3000);
-
[SOLVED] simple question about security with PHP Sessions
jacksonmj replied to pkedpker's topic in PHP Coding Help
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. -
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.
-
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)
-
[SOLVED] simple question about security with PHP Sessions
jacksonmj replied to pkedpker's topic in PHP Coding Help
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. -
$zipFileName = substr($realFileName,strpos($realFileName,"protect")+7); Change the +7 above to +8
-
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.
-
Might the following work? foreach($parents as $parent) { if (!$xml->$parent || ($xml->$parent == '') ) continue; foreach($xml->$parent->children() as $name => $node) {
-
I need help with converting HREF link to lowercase and dashes
jacksonmj replied to belick's topic in Javascript Help
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. -
onclick="showUser(document.getElementById('id').value)"
-
By "external", do you mean that it is on a different domain or subdomain? Perhaps post the relevant code?
-
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 }
-
AJAX chat script - not returning values?
jacksonmj replied to opalelement's topic in Javascript Help
The tutorial code seems to expect a "chat=[number]" in the URL when sending or receiving messages - so perhaps you should try something like: chat.php?action=chat&mode=get&last=0&chat=1 -
Hidden iframe perhaps? Give the hidden iframe a name and set the target of the form to the iframe name. Use onsubmit, returning false, to do the AJAX and cancel the hidden iframe submit if Javascript is enabled.
-
Have you tried: <body onload="history.go(-1)"> Perhaps (on a PHP processing page) header("Location: somepage.html"); ? Or maybe AJAX or a hidden iframe in the original form page?
-
Remember to only have one <body> and to put all content for display on the page inside it. If PassGood exists in any way, shape or form in $testit then isset will always evaluate to true. A SQL query will probably be returning a value for PassGood, even if it is only an empty value. Try looking at the output of print_r($testit) (note lack of quotation marks around $testit!) to check whether the isset($done) really is working.
-
Display the contents of a third party website page in a div
jacksonmj replied to lynxus's topic in Javascript Help
Either would work. On the one hand, iframes don't autoscale according to their content, so a document.write might be better. On the other hand, making sure you've escaped quotation marks properly can get rather complicated when you're outputting html through javascript through php. -
Use javascript, like the code below: function faqRedirect(selectBox) { var faqURL = selectBox.options[selectBox.selectedIndex].value if (faqURL != "") { document.cookie="SelectBoxPref="+faqURL.replace(/=/g,"#EQUALS#"); if (faqURL.substr(0, 4) != "http") faqURL = "../" + faqURL location.href = faqURL } } var cookies = document.cookie.split(";"); for (var i=0;i<cookies.length;i++) { if (cookies[i].indexOf("SelectBoxPref=")==-1) continue; var selectedUrl = cookies[i].split("=")[1].replace(/#EQUALS#/g,"="); var selectOption = document.getElementById("filter").firstChild; while (true) { if (selectOption.value==selectedUrl) { selectOption.selected = true; break; } if (!selectOption.nextSibling) break; selectOption = selectOption.nextSibling; } }
-
[SOLVED] PHP + javascript mouse over gallery help
jacksonmj replied to ashadweb's topic in Javascript Help
First replace "<?=" with "<?php echo" so that the PHP actually runs. Next add quotes around attribute values and onmouseover events, e.g. alt="Larger version of one of the smaller images above", onmouseover="document.rollimg.src=image0.src;" It is good practice to surround all attributes with quotation marks. Some, such as numbers, may not need them but most attributes will, so get into good habits. Then change name=rollimg to id="rollimg" and document.rollimg to document.getElementById("rollimg") . Referring to elements using document.name syntax will not work in most modern browsers. Then try your webpage again. And use the [ code ] tags on the forum when posting code. It's the "#" button just above the smilies. -
Try something like the following: <table id="addtable"> <tr><td>.... The original table content ....</td></tr> </table> <script type="text/javascript"> function addRow() { document.getElementById("addtable").innerHTML += "<tr><td>.... The row to add ....</td></tr>"; } </script> <input type="button" onclick="addRow()" value="Add">
-
Display the contents of a third party website page in a div
jacksonmj replied to lynxus's topic in Javascript Help
<script language="javascript" src="http://blaaa.com/data.php"></script> will do nothing unless data.php outputs valid javascript. <script> runs scripts, as opposed to inserting html files into the page. Have you tried an iframe? <iframe src="http://blaaa.com/data.php"></iframe> -
Expands to the right I need expand to the left
jacksonmj replied to rocketrud's topic in Javascript Help
You need to position the table relative to the right side of the screen. e.g. add "right:20px;" to the style attribute of the iframe, and it will expand to the left on mouseover.