Jump to content

txmedic03

Members
  • Posts

    313
  • Joined

  • Last visited

Everything posted by txmedic03

  1. [code]<?php $link = mysql_connect('localhost', 'user', 'pass') or die(mysql_error()); mysql_select_db('test') or die(mysql_error()); $query = mysql_query("SELECT * FROM people") or die(mysql_error()); if (mysql_num_rows($query) > 0) {   while($row=mysql_fetch_assoc($query)) {     print_r($row);     echo "\r\n<br /><br />\r\n";   } } mysql_close($link); ?>[/code]
  2. if (isset($_REQUEST['submit'])) if (isset($_GET['submit'])) if (isset($_POST['submit'])) This is the format you are looking for. Make sure that you put <input type="submit" id="submit" name="submit" value="Whatever" /> as this is the proper way to make sure submit sends a value. This is for compatibility with older browsers and xhtml standard compliance. I would suggest using if ($_SERVER['REQUEST_METHOD'] == "POST") provided that your form method will be "POST". If you use "GET" method this will not work because if you simply browse to a page the method will be "GET". I hope this helps.
  3. I've got some hair brained ideas on this matter, but nothing that is really fool proof, your question perplexes me greatly. If no one gives you any good ideas on this matter, I'll share with you some of my nutty ideas.
  4. [code] opendir('./');[/code] Use relative paths not URLs. ./ = current directory ../ = parent directory ../otherdirectory/ = directory on same level in tree with the current one subdirectory/ = a directory inside of the current one. You get the idea...I use the trailing slash because it makes it easy if you set a variable like $path = "subdirectory/"; then opendir() can open it and if you have a particular file like file.txt for example you can simply say $filenameandpath = $path."file.txt"; It could be done by remembering the '/' between $path and file.txt, so it really six of one half a dozen of the other, but this is just my prefered method.
  5. [code]mysql_query("CREATE TABLE IF NOT EXISTS `tablename` (`id` int(11) not null auto_increment, `field1` text(80) not null, `field2` text(80) not null, primary key (id))") or die(mysql_error());[/code] The id field will be incremented automatically so it will be unique. If you use phpMyAdmin or something of that nature you can set all of these things while creating the table through the user interface.
  6. [code]$filename = "{relativepath}/{filename}"; unlink($filename);[/code] You must make sure you have permissions on the file to remove/modify it.
  7. Well, it depends greatly on your server and what kind of features they disable/enable and how they configure sub-domains. If the sub-domains are simply directed to folders under the root directory then you can simply check to see if under the root directory [b] if (is_dir($subdomain)) echo "Sub-domain exists!"; [/b] or [b] if (!is_dir($subdomain)) echo "Sub-domain not found!"; [/b] depending on how you want it setup. There are a number of ways the server may be configured, but this is just one possible solution. If they use a 404 error when trying a sub-domain that doesn't exist you may consider checking to see if it returns a 404 error or not.
  8. It wouldn't be hard for the forums to show most recent 5 threads started by the user, but would it be useful? In my humble opinion, no. I'm sorry, but I'm not going to change my signature if I ever ask a question. I stay far too busy to worry about forum signatures. Now, would I follow a link to a forum thread to answer a question?...yes, I probably would, but only if it were formatted something like this: -------------- Unsolved Problem: http://Session Problem on PHP Newbie Help {date} I don't want to click on it and end up wasting time looking at a topic I am not well versed in myself. The date thing tells me how fresh the link is, if it is 2 months old I can assume that you just haven't changed your signature and it was probably already solved. Anything you can do to make sure you get the help you need without annoying everyone or breaking forum rules is a great thing, but I can tell you right now personally I would not click on a link to some topic if I didn't know what I was getting into.
  9. Two problems marker5a. 1) I believe that Spycat was refering to the forums here, not on a personal server so they can't change the php.ini file. 2) You should try to eliminate as much load time as possible. If you just keep cranking up your execution time out you could have an excessive load time that your users will not hang around for. 30 seconds should be more than enough. If your script executes longer than 30 seconds I strongly recommend you rethink your code.
  10. Akregator + RSS feed = quick and easy. I like it.
  11. I don't see the problem everyone is complaining about with loadtime and CPU usage. I notice one person meantioned a Duron 1.3GHz, I have not tried the site on anything lower than an Athlon 2500XP, but even then I didn't have a single problem with load time or CPU usage. My systems are as follows: AMD 64 (Socket 939) 2,000MHz 512MB DDR PC3200 SuSE 10.0 (gdm/gnome) DSL (620/310) Mozilla FireFox 1.0.7 Epiphany 1.8.0 AMD Athlon 2500XP 512MB DDR PC3200 Windows 2K Pro DSL (620/310) Mozilla FireFox (I forget what version it is) IE6 AMD Athlon 3000XP 512MB DDR PC3200 SuSE 10.0 (gdm/gnome) DSL(620/310) Mozilla FireFox 1.0.7 Epiphany 1.8.0 I browse this site answering questions and searching for tips that may improve my own coding while doing other things and I see absolutely no problems relating to the ads. I wish the site could run without ads, but in a perfect world we'd all have OC lines pounded in to our houses and money would grow on trees, but since we don't and it doesn't seeing ads is a small price to pay.
  12. I too would like to post some tutorials and/or scripts. If at all possible, I would like to know a time frame or possibly let me know if there is anything I could do to help expedite the process. Any feedback would be nice.
  13. Thanks norman I didn't even notice I left that off.
  14. I'll have to look over your code to be able to make suggestions on changes, but don't fear session_start(). session_start() does not mean that the user is logged in. It only means that you have a session where you can store information that will carry throughout the domain. With my particular script the session is not used for anything except creating a unique identifier for the individual that comes to the site. I think I'll probably work on a "lite" version later.
  15. There are ways to add error handling on your functions, but if you can help it don't use '@'. Don't hide your errors, fix them. In my years of PHP experience I have never had to use '@' to cover an error. I was always able to find a way to make everything work without suppressing errors. That's not to say that there are never situations where you might need the '@', just that they are not all that common. If every other line of your code is full of '@'s then you need to rethink your code a bit.
  16. If you provide more information like how the existing code is setup and what exactly you are looking for then I would be happy make suggestions.
  17. [code]if (!is_dir('users/'.$username)) {   mkdir('users/'.$username);   chmod('users/'.$username, 0755); }[/code]
  18. The sessions table has three user levels admin, user and guest (on my particular setup anyway). When someone visits the page it creates a "guest" session for the live counter to use. Since I wrote this to be integrated with a live counter, you would need to make some modifications so you do not need the session_start on the login page. It seems that you found something I overlooked when I wrote this code. When the user does not previously exist it returns an invalid query result. I have made the needed changes in my earlier post to fix the code. I look forward to any more questions or comments you may have. [code]if (mysql_num_rows(mysql_query("SELECT username FROM users WHERE username='".$_POST['username']."' LIMIT 1", $conn)) == 1) $error .= "Username already taken.<br />\r\n";[/code]
  19. Well the embedded error will depend greatly on the way you layout your code. You could simply do a [b]or die("formatted error result");[/b] at the end of your mysql commands. There are a couple of ways of doing this and getting the results you want, but it all depends on the layout of your code. This is just one basic example, but more then likely it isn't exactly what you are looking for. You could simply create a $header and $footer for the beginning and end of all your error strings to save yourself from typing lots of xhtml. Additionally, unless the server you intend to use specifically supports PHP5 then you should design based on PHP4. If your server does support PHP5 then you may want to check into thorpe's response.
  20. Well the first one that springs to mind is are you relying on register_globals? If you are you need to change your code so you do not need it.
  21. You need to check with your server to make sure they have PHP support and see what can be done to add index.php to the default document list.
  22. Just a note on the matter of changing server settings. I would recommend you only do this to fix problems if you are going to run the server yourself. If you change these limits on your development server to get around problems you encounter then you must do so on the primary server as well and if you use shared level hosting they probably won't let you make these changes.
  23. I would suggest using images for the simple fact that some people turn javascript off in their browser and using a form for each link in your site just leads to lots of superfluous code. Then of course the obvious question is, do you have any idea of the capability of CSS in this matter? You do know that the text does not have to be underlined or blue, right? You can even make the background behind it change colors.
  24. Most assuredly yes. Now the question is how exactly your page is formatted as to how to proceed. If no output has yet been generated you can use header("Location: {url}"). If this method will not work for you I could make other suggestions such as embedded errors or other methods of redirection, but for now we will just use header(). [code]<? $conn = mysql_connect('localhost', 'username', 'password') or header("Location: mysql_error.php?err=".urlencode(mysql_error())); ?>[/code] This attempts a connection to the server and if an error is encountered it redirects to a page to display the error. On the mysql_error.php page you need to decode the error and display it how ever you like. I'm not sure exactly what you want to do with it so I really can't be too specific here. [code]<? $mysql_error = urldecode($_GET['err']); ?>[/code] This may not be the method you want to use, but I hope I have at least pointed you in the correct direction.
  25. A MySQL database containing the images and the comments for each image and possibly a place for contact information or something along those lines.
×
×
  • 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.