Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by henryhenry

  1. Hi OK. Here's all the functions for my analytics. I have used snippets from various locations to put it together. Please note I use PHP to generate the js file hence the small amounts of <?php ?>. Thanks for your help!//-------------------ANALYTICS--------------------------//var xmlHttp; //ajax objectvar vapk; //the visitor pk which is retrieved on entry and used on exit to updatevar listeners = []; //arrayfunction listenAllLinks() { if (!document.getElementsByTagName) return false; // find links in document aLinks = document.getElementsByTagName('a'); // if link does have a id a
  2. Hi AllI'm using AJAX in an analytics script. All works nicely in Firefox and the script loads my php script which records some information in the database. The part with the error in IE is the part which adds the events to the anchor elements. The error message from IE is:Line 335: Object doesn't support this property or method.The javascript line this refers to (I have confirmed this 100% even though line ref is wrong) is as follows: links = document.getElementsByTagName('a'); As you can imagine I've tried looking for standard IE bugs for this type of line but nothing comes up. Some thought
  3. HiI'm trying to track links clicked. I am using PHP and MySQL to store the referer in the database then I have an onmousedown event on all links which calls a php script through AJAX. This script updates the database to add the link that the user has clicked on for that page.When I test the setup, I find that if I trigger the onmousedown event without clicking the link (ie click then move the cursor away), the script runs nicely and records the correct information. When I click for real, the script doesn't seemt finish running so the information is lost.Does anyone know how I can delay the
  4. Hi SpeedyzYeah, I do that at the moment, including a script with the mysql_connect() in it. I wondered if it's faster (in terms of performance) to use the object method?
  5. Thanks Yoshida!As an add on I am wondering whether to make the effort to convert to object-style for mysql stuff. I only just learnt object-style and I'm not really looking to spend hours converting all my connection bits to object style but if it speeds things up a lot then I might. Any opinions?
  6. Hello!I'm trying to choose the best method to optimise my site when connecting to a mysql database.The options that I can work out are:1. persistent connection (ie mysql_pconnect())2. normal connection - open at top of page, close at end of page3. open and close connection every time a query is performedMy site is pretty normal and I think I'm running about 20 or 30 queries on every page. (maybe that's not normal though?).I have been using the second option on that list. The site seems pretty slow and I've got the queries quite well optimised with lots of indicies, so I am thinking that the s
  7. henryhenry

    Links in CSS

    I think server-side scripting is the answer. For example you can just make a header, footer and menu and then include one file on every page. That way you're saving yourself lots of trouble changing every link.Eg. http://www.w3schools.com/php/php_includes.asp
  8. henryhenry

    im having truble

    HelloI was about to post a suggestion but I re-read your updated post. I have to agree with S@m... you need to be a bit nicer when people are giving out free advice.Good luckHenry
  9. I have to say I've never found using height:100% will actually work very well. What do you want it 100% of? And I think it's treated quite differently in different browsers. Agree with the 800x600 statement. My solution is to fix the width at a minimum to the width of the leftbar and the content then you get similar proportions to the 1024x800.Also I'm a bit confused as to why you use overflow:hidden on almost every tag. I think that's going to make your layout less fluid because if the content is more than the size of the div (as you define in your css) then the extra content will be hid
  10. Hopefully this hasn't double-posted...MySQL stores database information in (at least in my version (5.1 I think) ) a database called 'information_schema'. You can select all the table names with this query:SELECT table_name FROM tables;(you must select the correct database with "USE information_schema")You could use SQL to select only the tables that start with 'mots_' or whatever your tables are called. Or you could get them all and do that with PHP.I think mma_fighter's method is very clever for the loop. I used a less clever method with a switch in a function when I did something like th
  11. It sounds like you could get it working by improving the database structure - you could have the data recorded into one database table rather than two seperate tables in seperate databases. If you explain the problem more clearly and give some more information then it would be easier to think of solutions.
  12. Here's the php.net page http://www.php.net/manual/en/function.date.php with all the options for date.If you use firefox, create a search on the functions list (ie right click on the search input at the top right and select 'Add a keyword for this search'). Then you can search php functions from the address bar - much quicker!
  13. You want an SQL query that combines two columns from seperate databases into the same column?! Can't imagine why... Perhaps get both columns in seperate queries and use php to combine the data into an array? Then you don't have to worry about complex SQL joins, you just do two simple queries and use array_merge() with the results.You should probably post this on the SQL board as you'll get more responses.Henry
  14. I found some php functions have a character limit for the parameters. Maybe mysql_query can only take a certain number of characters in each parameter. In this case your query with two md5 values may have exceeded the limit. When you removed the password, the number of characters might have been low enough. If you substitute with a variable it might work?
  15. Maybe there should be a 'why not' statement in PHP?! That would be fun! Uh. I literally just did something like your doing. I put the 'LIKE' statements into an array so : $likes= array();foreach ($values as $k=>$v) { if (isset($_GET['this'])) { $this= $_GET['this']; likes[]= "word LIKE '$this'"; } elseif ...} then in the query you use implode(" AND ", $likes)or you can change to OR (can't mix with this method) if the likes are optionalso something like $sql= "SELECT col FROM table WHERE ".implode(" AND ", $likes); This method I suppose isn't simpler as you're using more loops
  16. Hi Jesh!That works a dream! Thank you!!!Henry
  17. The way I see it, every table needs at least one column which always has a value, never changes and whose value is unique for each record (OK I stole those three things from a book!). It makes sense though. If you have a table and a row has no values then when you try to look something up it will be very confusing for you and for your db. If you have some data that change regularly (like most data) and you try to look it up after a month of it changing, you will have no way to compare or understand what the data is refering to. Finally if you have two rows with exactly the same data in eac
  18. HiI'm trying to join these two tables. The second one is to relate items in the first one to other items in the same table (ie apple is associated with apricot, banana, orange):Here is the primary table +------------+---------+| pk | item |+------------+---------+| 1 | apple || 2 | pear || 3 | banana || 4 | apricot || 5 | orange |+------------+---------+ This table relates items in the first table to each other using the pk (refered to as fk_1 and fk_2) +-----------------+--------------+--------------+| rel_pk | fk_1 | fk_2 |+-----------------+------------
  19. I normally use ' as I read it was faster. So with variables I'm doing something like$s= 'string';$string= 'this is a string with another '.$s.' in it';should I use " {} "?
  20. So I've been using mysql_fetch_array($result, MYSQL_ASSOC) (or MYSQL_NUM) rather than mysql_fetch_assoc (and _num)Is there a difference in speed between using the function or the constant?
  21. This is from the mysql manual...LAST_INSERT_ID()LAST_INSERT_ID(expr)Returns the last automatically generated value that was inserted into an AUTO_INCREMENT column. mysql> SELECT LAST_INSERT_ID(); -> 195 eg: mysql> UPDATE sequence SET id=LAST_INSERT_ID(id+1);mysql> SELECT LAST_INSERT_ID(); Maybe it can also help? Once you have the insert_id you can easily update, select or whatever
  22. Hi Thanks for your reply. I'm going to have a think about what to do...My index works quite nicely although there are a few more limitations to work around. I have not found Fulltext search very effective for some reason. I think because I want to search a variety of data from across various tables. Maybe my site isn't structured so brilliantly! I'm still learning!
  23. henryhenry


    OK - spot the idiot who didn't read the article on php.net properly. Now I see that you don't need to output the result, it does it automatically. Sorry!
  24. henryhenry


    HelloI am trying to use uasort for an array like this (first code box). I am trying to have it ordered by the rank, keeping the array keys and structure the same. When I run it in my code, I get bool(true) result, rather than another array. I can't see where I'm going wrong... $array is - [0] =>- - [item] => hello- - [rank] => 20- [1] =>- - [item] => world- - [rank] => 35- [2] =>- - [item] => help- - [rank] => 23 The compare function I'm trying is as on php.net (but I added ['rank']) function compareRank($a, $b) { if ($a['rank'] == $b['rank']) { return 0; }
  25. henryhenry


    What about this function (assuming you use mysql)? Use ' ' as the delimiter. You would probably need another function to count the number of words. Why don't you use php to do this - surely it's easier?SUBSTRING_INDEX(str,delim,count)Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned. mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2);
  • Create New...