Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. An index on sales_pitch(10) means only the first 10 characters are in the index. So that's no use for fetching the data from the index.. it will have to scan the table itself. Thanks misc, I learnt something today
  2. What about this: "It is possible that key will name an index that is not present in the possible_keys value. This can happen if none of the possible_keys indexes are suitable for looking up rows, but all the columns selected by the query are columns of some other index. That is, the named index covers the selected columns, so although it is not used to determine which rows to retrieve, an index scan is more efficient than a data row scan." http://dev.mysql.com/doc/refman/5.1/en/explain.html It may be deciding that since all data is available in an index, it's finding the data with a "full index scan" instead.
  3. Which files could you open and which couldn't you open?
  4. From my testing, the session cookie is set and accepted by IE from new.php. But the cookie is not sent to links.php. In firefox it works, and the session cookie goes to links.php A possible workaround might be to manually send the session ID to links.php. I'm not sure why it's happening like that though..
  5. Can you show us your actual explain output? Your query only has one condition, and that is the join condition. In this case, I would expect the left table to be scanned entirely, followed by joining with the right table. I would not expect an index scan on the left table, because there is no point fetching an index when you want every row. If you added a WHERE condition affecting the left table (deals) , then it's possible that an index would be the best plan.
  6. Can you post all of both scripts? Sessions usually work, so I suspect it's something in the details of how you are using them. Did you use session_start() in both scripts?
  7. Lamez, be aware that users can change the value of cookies. So they can set their own username, and also set themselves as logged in when they really aren't. If you're planning to make this script public, I would recommend using sessions. Sessions are also much easier to use. They are based on cookies, but are more secure, and hide most of the messy stuff from you.
  8. Please show how you are using the query, especially the call to mysql_query(), as well as any error checking you are doing.
  9. You want this while ($flag == 0) Single = is assignment, double == is comparison. Triple === is strict comparison. You could have found this bug by adding some print statements inside your while loop, and seen that they were not executed.
  10. For your second question, that can only be done by a lookup table, not an algorithm. Unfortunately I can't help you with finding the table. Basically you need a table showing each accented character along with its plain equivalent, for every language that you plan to handle, and for whichever encoding you are using (utf8?). Then you just run the string through that table, making the appropriate conversions.
  11. perezf, can you post your script?
  12. I suspect your friend's program had a pre-programmed list of passwords and hashes, and it just looked yours up. Was your password something common, like blink182 or trustno1 ? If you picked a password like NtEtG!#1 and the program could find it, THEN I would be worried
  13. Just to clarify, the "md5 decryption" sites apply to unsalted passwords only. If you use a salt, those sites will be unable to find your original passwords. The hacker will need to use brute force, which is still very slow for md5. The purpose of using md5 (or another hash) is for the case where someone has hacked into your website, and has downloaded your password list. Then you want to make sure they cannot recover the original passwords (or not easily, anyway). Often, people will use the same password for different sites, so knowing your password to one site may give a hacker access to other sites, so this is why you want to keep the password unknown even if a hacker has control of your site.
  14. The reason it doesn't work with require() is that require() actually produces the output. Instead, you will need to return instructions on doing the output, something like this: function foo() { return 'htmlandphpmarkupincludefile.php'; } $phpinclude = foo(); require($phpinclude); Because require() appears outside the function, the display will occur outside the function. If you put require() inside, even in the return statement, the output will be produced inside the function. An alternative is using output buffering to catch the output.. it is much the same, but instead of returning the name of the included file, you will catch the output of the included file and return the output as a string, to be displayed later.
  15. The reason for the error is that unset is not a function, it's a php construct. It can't be used in some contexts (like inside a ternary operator).
  16. If you want to get $new_id from the session, you should do this: $new_id = $_SESSION['new_id'];
  17. Can you post the rest of your script? I don't understand your description of what your code is supposed to do either. And please describe in detail what "the if(in("submit")) function is not working" looks like. What do you see on the screen? What did you expect to see?
  18. You will need to post your script for us to help you with that.
  19. http://sg.php.net/manual/en/function.fsockopen.php Although the manual doesn't specify, I expect the timeout is in seconds. Typical values would be 60, 30, 10, 1, 0.2, depending on what your situation is. It depends on how long you are willing to wait
  20. What is in() ? It is not part of standard php.
  21. Try this: $newtext = preg_replace("|$searchterm|i", "<FONT style=\"BACKGROUND-COLOR: yellow\">$searchterm</FONT>", "$text"); Changes are: 1. str_replace => preg_replace 2. "$searchterm" => "|$searchterm|i" The "i" means "case-insensitive", which is the change you wanted to make. If I had written "|$searchterm|", it would act exactly like str_replace.
  22. If checking if a new user has the same name as an old user, something like this is enough: $sql = "SELECT * FROM users WHERE username = '$new_user'"; $result = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($result) > 0) { print "$new_user already exists!\n"; } else { print "$new_user really is new!\n"; }
  23. You can do that.. one way to do it is like this: $pages = array( 'index', 'news', 'contact', ); switch($_POST['page']) { case 'index': include('index.php'); break; case 'news': include('news.php'); break; case 'contact': include('contact.php'); break; default: include('index.php'); break; } It's always best to list the pages explicitly, so people can't access your files by inventing new pages. Another method is with Smarty (what I use). With that, your templates are stored in seperate files (which are also capable of including each other). If you have a small project, the php method above is fine. For larger projects a system like Smarty helps greatly, as it seperates processing from design, as you said.
  24. What error does it give?
×
×
  • 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.