Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. To keep music playing while users browse the site, you have to do one of three things: 1) Code your site so you never technically load a new page. This means using AJAX to load all your content 2) Open a popup window and have the music play in the new window 3) Use frames to split the site from the music player.
  2. Assuming this is related to your previous thread about updating something every 30 minutes, a fairly simple approach would be to do something along the lines of this: http://jsfiddle.net/cKeNs/ <script type="text/javascript"> (function(){ var secondsSince = <?php echo secondsSince(); /* Have this return # of seconds since last update */ ?>; function update(){ secondsSince++; var thirtyMinutes = 60*30; if (secondsSince >= thirtyMinutes){ var msg = 'Now'; //Optionally you could kick off an ajax request to the server so it can process the fact that a new turn is available. } else { var minutesRemaining = Math.floor((thirtyMinutes-secondsSince)/60); var secondsRemaining = (thirtyMinutes-secondsSince)%60; var msg = minutesRemaining + ':' + secondsRemaining; } document.getElementById('timeDisplay').innerHTML = msg; setTimeout(update, 1000); } update(); }()); </script>
  3. Your missing a closing parenthesis. function update() { $.ajax({ url: 'updateturns.php', dataType: 'text', }); } Note that trying to make an ajax request to your server every second would likely destroy your server's performance. As recommended earlier, you should just do everything in JS locally on the client end without having to contact the server.
  4. You can't use parameters for table names. Parameters are only valid for values.
  5. Two possible options I can think of, the first being a sub-query for the totals: http://sqlfiddle.com/#!3/96e2b/3/0 SELECT * FROM tblA INNER JOIN (SELECT ID, COUNT(*) as rows FROM tblB GROUP BY ID) as total ON tblA.ID=total.ID INNER JOIN (SELECT ID, Type, COUNT(*) as rows FROM tblB GROUP BY ID, Type) as groupTotal ON tblA.ID=groupTotal.ID WHERE groupTotal.Type=0 AND total.rows=groupTotal.rows The second being a query using GROUP BY and a HAVING filter: http://sqlfiddle.com/#!3/96e2b/6/0 SELECT tblA.ID as aid, tblB.ID as bid FROM tblA INNER JOIN tblB ON tblA.ID=tblB.ID GROUP BY tblA.ID, tblB.ID HAVING SUM(CASE WHEN tblB.Type=0 THEN 1 ELSE 0 END)=COUNT(tblB.ID)
  6. Pretty self explanatory: Table 'rdb.rest' doesn't exist. You're attempting to query a table called rest in a database named rdb, but it doesn't exist.
  7. The hashed structure sounds like a pretty good general-purpose structure to me. I may end up using that in the future.
  8. Based on the Inetpub in your path, I am assuming you are using IIS as your server. In that case the user would be defined by the application pool that the site is using. You should be able to find it in the IIS config somewhere, exactly where depends on what version of IIS you are using. Under a default setup the user is usually called IUSR_machineName where machineName is the name of the computer. A quick hack would be to just grant 'Full Control' to the pseudo-user Everyone (roughly equivalent to chmod 777 in a linux environment).
  9. For a windows server, the equivalent to chmod would be the Security tab in the file's Properties dialog. Go there any make sure the user the script runs as has the proper permissions to modify the file (and possibly the directory it is in).
  10. Your comp radio buttons need to have different values. Right now you're setting them all to the same value so there is no way for you to distinguish which one was actually checked when the form was submitted.
  11. Enter it where? And for what language? For PHP you can already do something like that by just going to http://php.net/function_name_here.
  12. You shouldn't name your inputs the same like that. PHP will only keep one of the values, which one depends on the order in which they were submitted (which generally is source-order). I gather you did that so that $_POST['hdd'] will be set to '-' if the checkbox is not set, but a more proper way would be to only have the checkbox and then process it as: $hdd = isset($_POST['hdd'])?$_POST['hdd']:'-';
  13. There isn't any way (afaik) to simply remove a style definition from one rule inside another, you can only override it's value. You'd just have to override it and reset it to it's "default" value.
  14. A CMS is fine if it fits into what you need it to do. The more you need it's functionality customized though, the harder they can be to work with. There isn't any one-size-fits-all solution when it comes to website construction. You have to analyze what you want to accomplish with your site and then do some research to determine if it is something you can accomplish with an off-the-shelf CMS (w/ plugins possibly) or if you'll need to do some custom coding.
  15. Google for example does take the HTML into consideration when indexing a site. For instance, text in <h1> tags will be considered a little more important/relevant than just normal paragraph text. Another thing is google may not find the URLs to other pages on your site without them being within <a> tags. I'm not sure whether google will scan the plain text for something that looks like a URL or not. I agree with Psycho though, I see no reason why you would choose to do this with Javascript rather than PHP. You can control PHP and make it work how you want. With Javascript you're at the mercy of the end-users browsers / web crawlers and have to work around their limitations.
  16. No, rather than ending up with one giant directory full of files (or directories) they get spread out over multiple directories. If you just stuck it all into one directory and for some reason ever needed to go into that directory to do something you may have problems with things not handling a large number of files very well. If you want to have each user have their own folder, then you probably don't need to split the files up like that, just store them into the folder. You might consider splitting the user's folders up that way though to prevent having a bunch of users folders in the same parent directory. Such as maybe: Uploads/users/3/3456/somefile.jpg where 3456 is the user's ID#
  17. I'm not to familiar with expect, so I can't help much there. However I have a few alternative suggestions you could implement instead of using expect: a) Try using the SSH2 extension for PHP to connect and do what you need from within PHP rather than attempting to exec() an external utility or b) Setup public-key based authentication to allow you to login without needing to enter in a password.
  18. You can't specify the id attribute twice.
  19. Splitting them up by UserID would work ok. You may consider splitting up the user's directories also if you expect there may be a lot of users. An alternative to splitting things by user id would be to just rename the file using either a random name, or maybe an auto-increment id of the row where the file details are stored. To split things up, one thing I do whenever I expect there may be a lot of files is divide them into sub directories based on the first couple letters of the name. For example if I wanted to store the file 1928_somefile.jpg it would be stored into $UPLOADDIR/1/9/1928_somefile.jpg. Basically a table like you mentioned is all you need to setup the connection. You don't really need a separate auto-increment PK column though, just set your PK to be (userId, friendId). The combination should be unique and would be enough to identify the relationship in the table.
  20. You would setup a Cron Job in order to run a script on a schedule such as every 30 minutes. Based on your description though I don't think this is really what you need/want. Store a timestamp of when their turns last updated. Then you can calculate the # of minutes between the last update and now to determine how many turns need to be granted to them as well as how much time is left on the clock. As a rough example (assuming Mysql & PDO): $db = new PDO('mysql:...'); //connect to db //Assuming $userId is their sytem ID $minutesSinceUpdate = $db->query('SELECT TIMESTAMPDIFF(MINUTE, lastUpdate, NOW()) as minutes FROM users WHERE userid='.$userId)->fetchColumn(0); $numTurns = floor($minutesSinceUpdate/30); $minutesLeft = $minutesSinceUpdate%30; //Update the lastUpdate time to now, adjusted for # minutes remaining $db->exec('UPDATE users SET numTurns = numTurns + '.$numTurns.', lastUpdate = NOW() - INTERVAL '.$minutesLeft.' MINUTES WHERE userId='.$userId); On second though, you might even be able to wrap it up into a single update: UPDATE users SET numTurns = numTurns + FLOOR(TIMESTAMPDIFF(MINUTE, lastUpdate, NOW()) / 30) , lastUpdate = NOW() - INTERVAL TIMESTAMPDIFF(MINUTE, lastUpdate, NOW()) % 30 MINUTE WHERE userId=12345
  21. Check your query results, make sure it is ordered'd correctly. The code depends on all the room's of the same type being together in the result-set. The sample output you're posting shows them alternating. edit: Just noticed: ... order by 'iroom'"; iroom should not be in quotes.
  22. One thing I can tell you is that your code generates invalid HTML. You should fix that and see if you still have a problem. Given iroom | iname ------------------------- Room 1 | Name 1 Room 1 | Name 2 Room 2 | Name 1 Room 2 | Name 2 You would end up with HTML looking like: <table align="center" style="width: 700px"> <tr> <td colspan="5"> <b><u>Room 1</b> </td> </tr> <tr border="1"> <td class="auto-style5">Name 1</td> </tr> <tr border="1"> <td class="auto-style5">Name 2</td> </tr> </u></b></td> <td colspan="5"> <b><u>Room 2</b> </td> </tr> <tr border="1"> <td class="auto-style5">Name 1</td> </tr> <tr border="1"> <td class="auto-style5">Name 2</td> </tr> </table>
  23. That is not true. Google indexes https just fine. My site forces the use of SSL for everyone and it exists in google's indexes just fine.
  24. I think the question here is why the f*** are you using windows 95? Why not use a newer version, or linux distro? Those answers would be no, no, no, and almost no.
  25. These should get you started. If you can't get it working, post whatever code you've tried to write: OOP Basics Properties
×
×
  • 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.