Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. Wrong approach. What you should have is a row for each friend. Your structure supports this fine.
  2. You're going down the wrong path-- xhtml is about using a prescribed set of tags in a standard way, not about naming your files .xml.
  3. file_exists function provides this for you. $filename = '/path/to/foo.txt'; if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } ?>
  4. With mysql you can turn on the slow running query logging. There are a few ways to do this, but the one I'd suggest is adding this to your mysql configuration file, which is typically named my.cnf. It's often in the /etc directory or /etc/mysql directory, but that depends on your server config. Edit it to add this under the [mysqld] section # Logging set-variable=long_query_time=5 log-slow-queries=/var/log/mysql/slow-queries.log You might need to change the file path to suit your server config -- for example I assume here you already have a /var/log/mysql directory. You can also play with the long_query_time making it longer or shorter (it's in seconds). You have to restart mysql after you make these changes. Once that's working you should open up a shell and tail -f the file, then watch your server run through it's paces, and test things. You'll see the queries that are taking a long time. If you find queries that are tablescanning then you'll look to see whether there is a sensible index that you can add. Beyond that there are entire books on query optimization. It's too complicated a subject to dash off a simple reply.
  5. Agreed. I did try and answer the original poster, but he seems to have gone dark -- even PM'd him. I'm about 99.9% sure it's a permissiosn problem.
  6. Typical way of doing this is to store rows in a database table. Take one of those tutorials you mentioned, and get the code working, and ordering is trivial. When adding and ORDER BY clause to a sql statement the default is Ascending order. To reverse that and have it be Descending you simply tack on the DESC keyword to the ORDER BY. SELECT * FROM yourtable ORDER BY postdate DESC Voila, newest posts first.
  7. With that said you can use reserved words as column names, but you have to enclose them like so: `primary`. Now to the bigger question --- your table structure has implemented the classic repeating group (primary, secondary, third) which I assume from the example is a foreign key to a Breed table. Really that should be a many to many. Tables should be dog_account, breed, dog_breed, where dog_breed is something like: (dog_id, breed_id, percent). Then you wouldn't have to construct ugly or queries like the one you're doing now.
  8. The PHP manual says that move_uploaded_file() will issue a warning with some more info when the file can't be moved. I think you're on the right track in thinking it's a permissions problem, probably of the directory where you are trying to write it, although you didn't provide your code snippet, and you could have a problem with your destination file path. Are you running php as fastcgi or as mod_php? If mod_php then the user that needs the permissions to rw to the destination directory is the user that apache runs as.
  9. No i wasnt suggesting an answer just another question on how I could use a variable to save the file. In answering you I completely blanked out on the fact you wanted to use a variable -- I amended the code example so it uses a variable. As I stated, No problem, you can do it.
  10. Great to hear, and thanks for providing an update for future readers.
  11. His code makes no attempt to read from the filehandle, so there's no reason to open the file with 'a+' mode. Opening with 'a' is fine here and does work. As I posted previously I'm fairly confident this is a file permissions problem. By default this will try to write in the same directory as the executing script, and probably the Apache user doesn't have permissions to write to that directory.
  12. My guess is that this is a permissions problem. Is this on a windows or Unix server?
  13. Certainly, although the "." is a reserved character in php used for concatenation, so you have to build the file name like so: $fp = fopen($user_name . '.txt', 'a');
  14. The include process does indeed bring the code into the current script in the order in which it was specified. Ultimately you can think of your executing script as one giant static script where the full contents of any included scripts replaces the include statement at the exact point that it's included. Yes includes have a cost, but that is not something you need to worry about too much, as without them PHP would probably be close to unmaintainable.
  15. I'm afraid I'm not following you. PHP provides the $_POST superglob, that has the contents of every form variable, hidden or not. It's an associative array, so accessing the contents is trivial. This data all comes in via HTTP but Apache and PHP parse it into pieces that make it convenient and easy to work with from within PHP. Look at all the data that comes from phpinfo().
  16. I think you misunderstand the issue. The issue is NAT where you could have hundreds or even thousands of users with the same IP (remember AOL?). Ok, it's an overstated concern, but it's not a matter of reuse of IP's, but rather that NAT allows the same IP to be used simultaneously by multiple users *at the same time*.
  17. Like all serverside programming languages, PHP takes the information received in the headers and in most cases makes it available in the superglobals like $_POST, $_SERVER etc.
  18. By default, PHP sessions do create cookies. This is actually a *good thing* IMNSHO. Pulled directly from the PHP manual --- // Initialize the session. // If you are using session_name("something"), don't forget it now! session_start(); // Unset all of the session variables. $_SESSION = array(); // If it's desired to kill the session, also delete the session cookie. // Note: This will destroy the session, and not just the session data! if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time()-42000, '/'); } // Finally, destroy the session. session_destroy(); ?>
  19. You can do what you want using Ajax/Javascript. It's non-trivial, but not incredibly difficult either. If the dependency on the dropdowns is derived from the database, then Ajax is a good way to handle it --- no reloads required. Hopefully you are able to do some javascript coding.
  20. Use this at the top of your script to set the reporting: http://us2.php.net/manual/en/function.error-reporting.php
  21. You are best off using UTF-8. In Oracle that would be ALS32UTF8 or UTF8 characters sets. Is that the character set you are using?
  22. Piba, Can you tnsping the database from that server? It seems like you have a problem with your connect string. If you can construct a valid tnsnames.ora entry and tnsping it, then that should allow you to connect using the verbose format.
  23. So it sounds like you know where to look for you error: in the routine that determines whether or not to display the next button.
  24. The text is written using the imagestring($NewImage, 10, 20, 8, $ResultStr, $TextColor);// Line. I'm not sure why this works, because the 2nd param, is suppossed to indicate the Font. Theoretically, making 10 something bigger would pick a bigger font, but it's not indicated in the manual that even a param of 10 is supported. Centering is tricky, you'd have to do a bit of math using the imagefontwidth() function. Theoretically, this value times the number of characters being added onto the image, would allow you to figure out where to start printing (x,y), by getting the 1/2 way point of the image, and subtracting 1/2 of the length of the string from that number (to get the X coord). Notice that currently the x,y values are hardcoded as 20,8, so you'd need to make those into variables.
×
×
  • 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.