Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. Huggie, I doubt it would work in explorer and safari if php wasn't installed :)
  2. Have you validated your HTML?  Very often errors are handled differently by different browsers, leading to different behaviour.  Even with valid HTML, you can get different behaviour. ACtually I see some invalid HTML already.  A table is structured into rows, like this: [code]<table> <tr> <td> </td> <td> </td> </tr> </table>[/code] A td can only exist inside a tr.  Both browsers should be able to handle that fine though, so i doubt it's the problem.
  3. The headers the web server is returning look like this: [code]HTTP/1.x 200 OK Server: Microsoft-IIS/5.0 X-Powered-By: ASP.NET Date: Wed, 13 Sep 2006 13:34:46 GMT Content-Type: application/octet-stream Accept-Ranges: bytes Last-Modified: Wed, 13 Sep 2006 11:08:59 GMT Etag: "c0a3f8225d7c61:de8" Content-Length: 3988 Connection: Keep-Alive[/code] The problem here is Content-Type: application/octet-stream.  It's a server configuration error that this conent-type is being returned.  Unfortunately I can't help you with fixing it, as I'm not familiar with IIS Maybe you can fix it by sending header("Content-type: text/html") from your php script.
  4. I think you're looking for a left outer join.  Do you want rows from table A which are NOT in table B? [code]$query="SELECT users.username FROM users LEFT OUTER JOIN surpool06 ON users.username=surpool06.surpool_username WHERE surpool06.surpool_username IS NULL";[/code] The left outer join will give you nulls for table B where no matching rows exists.  Then your "is null" will pick up only those rows.
  5. I've found perl to be considerably faster for regexp processing.  Your mileage may vary. As far as features go, PHP has them all.  There's a few getopts (Console::Getopt and just plain 'getopt).  And there's no features I've found missing..
  6. That is very odd.  Your code looks fine.  I'm pretty sure it's to do with the server, and your script is being called twice for each request.  You might want your script do dump the contents of $_SERVER and see if there's clues in there (use $server_vars = print_r($_SERVER, true))
  7. You can find the total number of entries with [code]$result = mysql_query("SELECT count(*) FROM `myob`, `diamond` WHERE diamond.Custom2=myob.Custom2 AND myob.Cat1= '$SCat1'"); if (!$result) die("Mysql error: " . mysql_error()); if (mysql_num_rows($result) != 1) die("Didn't get 1 row from count query??"); $row = mysql_fetch_assoc($result); $num = $row['count'];[/code] Not 100% sure that it's $row['count'], but the count is definitely in that array.  $row[0] will definitely get it. In Mysql using standard tables, count(*) is very fast.  Much faster than select * for sure. Still it's odd that your script times out.  Maybe you can try running it from the command line (Hardcode the arguments for this) and see what output it displays.  Can you tell us what indexes you have on those tables, and the number of entries in each table?
  8. Yep, Smarty templates.  Once you've started you won't be able to stop :) Headers and footers are usually a good idea.  But it depends a lot on your application.  It might make sense to abstract other things out too.  If you're using Smarty, you can have code in your "display a page" function that adds in the header and footer for every page.  Then there's no need to repeat that code everywhere.  If some pages don't use the standard header/footer, you can set a "don't load header/footer" variable before calling the display function. The system I work on currently uses apache to rewrite requests like /page.html to use the script page.php and the Smarty template page.html, and call the function page() to get the Smarty variables.  Then to make a new page you just create the template and the associated file, and off you go. Smarty templates include foreach loops, captures (eg, capture your pagination links and print them at the top and bottom of the page with only one set of code, but all still in the templates), and other nifty stuff.
  9. A little rambly :)  I'll try to clarify some things Can you give more detail about what "get from another directory" means?  Are you talking about forms, eg <form method=get>, or about links, eg <a href="page.php?var=value">?  Or something else? Also, are you using cookies or sessions (or neither)?
  10. It's not that straightforward, since sessions are usually identified with cookies.  And no browser will send a cookie it got from domain A to domain B. One option is to pass the session identifier explicitly, by adding "?session=" . session_id() to the link. Then your script on the receiving end can check for $_REQUEST['session'], and if set, call session_id($_REQUEST['session']) before session_start(). I think that ought to work, as long as both virtual hosts are storing session data in the same place.
  11. The mysql_*() functions have an optional "link identifier".  Adding that might fix your problem. [code] mysql_query($query, $this->conn)[/code]
  12. Let me guess, you are a C programmer? :) You can fetch a url simply with [code]$contents = file_get_contents('http://www.google.com');[/code] It returns false on failure (that's false, not 0!  They are different things in PHP).  Then you don't have to worry about concatenating anything. Also, you can loop through an array with [code]foreach ($array as $elem) {  .. do something with $elem .. }[/code] No need to count the array and use an iterator. As for strpos(), it returns false if the string is not found.  If the string is found, it returns the offset.  Again, false is NOT 0, it is false.  Return value 0 means the search string was found at the start of the string.  So, you should check [code]if (strpos($haystack, $needle) === false) { not found } or if (strpos($haystack, $needle) !== false) { found }[/code]
  13. Is the problem here that session data is not accessible on another host?  I'm unclear on your question.
  14. You need [code]$User[] = $FetchUsers['Username'];[/code] That will add the username into the next entry in the array. I assume that FetchArray() returns an associative array, not integer-indexed array.
  15. I think that this is what you want: http://sg.php.net/manual/en/function.htmlspecialchars.php For example: [code]$username_encoded = htmlspecialchars($player['username']); print '<input type=text name="username" maxlength=255 length=20 value="' . $username_encoded. '">';[/code]
  16. It's good practice to check mysql_query() for errors. [code]$result = mysql_query($query); if ($result === false) die("Mysql error: " . mysql_error() " on query $query\n");[/code] If that doesn't work, then print out your queries before executing them.  It's likely there's a problem with one of them.
  17. There's always a tradeoff between abstraction and efficiency. In this case, you can have a option or method for your class that says "I will be reading all images, read them in to a cache now".  Then your getImages() can check the cache and use that data if possible, with an sql query as a fallback.  It's some loss of abstraction, but you can't have everything :)
  18. stripslashes(extract($row)) doesn't do what you want it to do.  You need to call stripslashes() on the title directly. But that won't affect $id not being set.  Try adding [code]print_r($row); print_r($title); print_r($id);[/code] inside your while loop, after you call extract().  Maybe it'll show up something useful.
  19. Try print($_REQUEST['name']); You can also use $_POST['name'], since you are using a post form.
  20. First, you need to check for errors from mysql_query().  For example: [code]$result = mysql_query( ... ) if ($result === false) die("Mysql error " . mysql_error());[/code] Second, if you aren't already you should check the values of $playerdb and $member_vote to make sure they are valid. Then post back here if you are still having trouble :) I think it's likely your problem is here: [code]<td><select name="$member_vote" size="1">[/code] Should that be "member_vote" instead of "$member_vote" ?
  21. The mcrypt module allows encryption. http://sg.php.net/manual/en/ref.mcrypt.php If you are storing user's passwords, it's a better idea to use one-way encryption with md5().  You can always set the user's password to something new if they forget the old one.
  22. What are the symptoms when you try to view 1 thousand rows?  What happens? The most likely problems are lack of memory (see the "memory_limit" php.ini setting) or lack of time (Usually php scripts are limited to something like 30 seconds or 60 seconds.  I don't remember which setting controls that).
  23. Usually I use curl to download data from a website, and then process it.  That's about as deep as it gets :)  I am having a little trouble understanding your question..
  24. I can't help with specifics, but I can offer advice based on php/pgsql experiene.  If your script is hanging during a database call, then you can leave it running and inspect the database itself.  Get a list of running queries, and see if they are waiting on any locks, etc etc.  IS it possible there might be other scripts running that could case a deadlock?  I can't help you with specific commands to do that under Mysql though. I assume that your "fputs($fp, ...)" commands would normally be database queries?
  25. You could set a variable.  Variables set in index.php can be seen by main.php.  For example [code]... } else {   $editbutton_displayed = true;   require_once "main.php"; } And in main.php: if ($editbutton_displayed != true) {   editbutton(); }[/code] Another name for the variable could be "$in_index_php", which might be more appropriate.
×
×
  • 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.