Jump to content

fohanlon

Members
  • Posts

    65
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

fohanlon's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi Guys I have a string with a max characters of 612, this equates to 4 strings each of length 153 characters. Here is the issue, for every euro symbol in each of the 4 substrings each takes up 2 characters. So for example if there are 5 euro symbols in the first set of 153 characters, I want to push 5 characters into the second set of 153 characters as each euro takes up 2 characters and adjust the 3rd and 4th 153 substring accordingly and so on. Also there is the added complication if there are euro symbols in the last few characters of each 153 characters substring. I canot find a suitable function to help here. I was thinging of starting with: $num_euros1 = 2 * substr_count(substr($Content, 0, 153), '€'); $num_euros2 = 2 * substr_count(substr($Content, 153, 153), '€'); $num_euros3 = 2 * substr_count(substr($Content, 306, 153), '€'); $num_euros4 = 2 * substr_count(substr($Content, 459, 153), '€'); I am stuck on this one. Regards Fergal.
  2. Hi I am reading the contents of a file into a variable as follows: file_get_contents($pathtofile); If the file contains say just 3 € (euro) symbols as an example and I output the strlen I get 9 instead of 3. Could anyone tell me how I could sort of the contents (the 3 euro symbols) so I can get strlen as 3. I tried utf8_decode etc. Many Thanks Fergal.
  3. Hi Guys After searchign the web and forums I still cannot find a suitable solution for my problem. I have a textarea. Say the user copies in from MS Word the following: “!"£$%^&*()@'#:;/?!"£$%^&*()@'#:;/?!"£$%^&*()@'#:;/?!"£$%^&*()@'#:;/?!"£$%^&*()@'#:;/?!"£$%^&*()@'#:;/?!"£$%^&*()@'#:;/?!"£$!"£$%^&” Before I save it to a database I want to clean it up i.e replace or remove the  I have read that the  will take up 2 characters. Also, if I could also replace MS Word single and double quotes that would be great. I was looking at the str_replace with the Chr() function but to no use. Thanks for reading. Regards Fergal.
  4. Hi Guys Trying to get my head around a mod_rewrite I am doing. I found plenty on the web re this question but no definitive answer. Here is what I have to do. I have a link to a page called content.php?id=123&name=SOME NAME HERE where id ties back to the 123 for pageid and name is what I want to use for Search Engine Optimisation. So here is what I have so far: RewriteRule ^([^/]*)/([^/]*)$ /content.php?id=$1&name=$2 [L] But what I want to do - only show the name in the url at the top Instead of www.somedomain.com/123/SOME NAME HERE I want www.somedomain.com/SOME NAME HERE but still need to use the id to pull back the page content to be displayed. Can anyone suggest how to change the rule above? Hope this makes sense and its the right place to post this. Many thanks Fergal.
  5. It would but what about the words that are not 11 characters. 11 is the max length and I want to return any words from string length of $q up to 11 characters that begin with $q. I can do it using LIKE but thought I could get away with using REGEXP instead.
  6. Hi Guys I am having trouble with a mysql regexp expression called through php. I am not sure but I suspect its to do with the {} in the mysql code and PHP parsing them incorrectly. Here is my code snippet: $q = mysql_real_escape_string($_POST['keyword']); $limit = 10; //limit number of responses from dictionary $remainder = 11 - strlen($q); if ($q) { $qy = "SELECT * FROM dict_list WHERE UCASE(word) <> UCASE('$q') AND (word REGEXP '^$q.{$remainder}') LIMIT $limit"; $query = mysql_query($qy); ... What I want to do is this: a user types in a word. I then want to query a dictionary table called dict_list for all matches of the this word up to 11 characters max. Example: if $q was the word aero then the response would be all words beginning with aero and up to a max of 11 characters. That is why IU thought I could calculate length of $q and from this get the $remainder = 11 - strlen($q) then in the REGEXP use .{$remainder} but when testing if I echo out the query $qy the curly braces will not show on screen. Any help would be greatly appreciated. I hope this is posted in correct location. Apologies if not. Thanks, Fergal.
  7. Hi Do I check php user permissions on the server, is it in the php.inf file? F.
  8. Hi I want to be able to upload files to subdrectories on the server. I do not want to set any folders to permanently 0777. Here is what I have so far, its a combo of my own and somw stuff found on the web. It will chmod the parent folder but fails on the sub folder. I read about creating the parent folder using FileZila can create problems. Confused as to what to create the parent folders in. Thanks in advance. F // documents $path_to_parent = "/httpdocs/sub1/subs2/"; $parent_folder = "myfiles/"; $sub_folder = $parent_folder . $subdirectoryid; function chmod_open() { $ftp_details['ftp_user_name'] = FTP_USER; $ftp_details['ftp_user_pass'] = FTP_PASS; $ftp_details['ftp_root'] = FTP_ROOT; $ftp_details['ftp_server'] = FTP_SERVER; extract ($ftp_details); $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); return $conn_id; } function chmod_file($conn_id, $permissions, $path) { $ftp_root = '/httpdocs/sub1/sub2/'; if (ftp_site($conn_id, 'CHMOD ' . $permissions . ' ' . $ftp_root. $path) !== false) { return TRUE; } else { return FALSE; } } function chmod_close($conn_id) { ftp_close($conn_id); } // Connect to the FTP $conn_id = chmod_open(); // create folder if it does not exist if(!file_exists($_SERVER{'DOCUMENT_ROOT'} . $path_to_parent . $sub_folder)) { chmod_file($conn_id, 777, $parent_folder); mkdir($sub_folder, 0755); chmod_file($conn_id, 755, $parent_folder); } if(file_exists($_SERVER{'DOCUMENT_ROOT'} . $path_to_parent . $sub_folder)) { echo chmod_file($conn_id, 777, $parent_folder) ? 'CHMODed successfully!<br>' : 'Error<br>'; echo chmod_file($conn_id, 777, $sub_folder) ? 'CHMODed successfully!<br>' : 'Error<br>'; // upload files here - docupload if($_FILES['docupload']['size'] != 0) { $tempname = $_FILES['docupload']['tmp_name']; $actual_filename = $_FILES['docupload']['name']; $search = explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u"); $replace = explode(",","c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u"); $actual_filename = str_replace($search, $replace, $actual_filename); if(!move_uploaded_file($tempname, $sub_folder . "/" . $actual_filename)) echo "failure<br>"; else echo "success<br>"; } // delete files here if applicable - delete_file[] if(count($_REQUEST['delete_file']) > 0) { for($i=0; $i < count($_REQUEST['delete_file']); $i++) { $f = $_REQUEST['delete_file'][$i]; unlink($f); } } echo chmod_file($conn_id, 755, $parent_folder) ? 'CHMODed successfully!<br>' : 'Error<br>'; echo chmod_file($conn_id, 755, $sub_folder) ? 'CHMODed successfully!<br>' : 'Error<br>'; } // Close the connection chmod_close($conn_id);
  9. Hi Jcbones I did as you mentioned and I put a echo "<script>alert('here');</script>"; message in my php code on form submission but in FF nothing is happening. Not even the alert I have in the function AutoSave is appearing. really stuck on this one. Thanks for the help. Fergal.
  10. Hi Below is the code I am using (found after a net search - not mine). I load init() in body on page load.: function init() { window.setInterval(autoSave, 20000); // 20 seconds } function autoSave() { var status = document.getElementById("status").value; var params = "?status=" + status; var http = getHTTPObject(); http.onreadystatechange = function() { if(http.readyState == 4 && http.status == 200) // 200 = HTTP OK { // alert(http.responseText); alert("All data for this current participant has been auto saved"); } }; http.open("POST", "mypageaddress.php" + params, true); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.send(params); } //cross-browser xmlHTTP getter function getHTTPObject() { var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/ if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; } The page will refresh and I have a php function to update mysql tab if($_SERVER["REQUEST_METHOD"] == "POST") { } but this is not being executed. Thanks, Fergal.
  11. Hi Guys I want to be able to autosave a form content every X seconds, I coded it using php and javascript getHTTPObject() function but it will not work. Can anyone point me to a php solution to autosave a form Kind Regards, Fergal.
  12. Many thanks. I came across phplivedocx alright. But its lmited to doc, docx and rtf. It cannot support excel or powerpoint conversions so I was told.
  13. Hi Guys Does anyone know of or could you point me in te right direction for php code to convert uploaded word, excel or powerppoint files to pdf. Can it be done as part of the file upload process - what software could do this? I have searched the web and there are plenty of website that allow you to upload a file and it will convert it for you but there are few sites that have the code to do this? Many thanks, Fergal.
  14. Hi Guys, Does anyone know how to color the text in a subject line when using the mail function. Is it simply a case of using html wrapped around subject text? Many thanks, Fergal.
  15. Hi Guys I want to create anchor tags. I know how to do this with html. Here is my problem: <a href="#myanchor">Go to my anchor</a> Then I have the <a name set up But the page reloads with a url as follows: mypage.php?id=19#myanchor Where id is an id of a page in a mysql db to pull content. I have a mod rewrite so the above url is mypage/19#myanchor Any help to solve this word be appreciated thanks Fergal. This is not working
×
×
  • 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.