Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. btherl

    ORDER or NOT

    Have you timed the queries? If you query without ordering, then mysql will simply return the first 900 rows (as stored on disk), which will be quite fast. That's fine as long as the first 900 rows are what you want. If you use order by, mysql can use an index on the order condition to find the first 900 rows in that ordering. I would expect it to be slower though, as each row may be in different pages on disk, and the index must also be read in. Benchmark it and see An order by without an index will be much much slower, as it must sort the entire table before taking the first 900.
  2. There's this note in the docs for that function: "Note: Libxml 2 unescapes the URI, so if you want to pass e.g. b&c as the URI parameter a, you have to call simplexml_load_file(rawurlencode('http://example.com/?a=' . urlencode('b&c'))). Since PHP 5.1.0 you don't need to do this because PHP will do it for you." But easier might be to grab the whole thing and then pass it to simplexml. Try this: $xmlstr = file_get_contents('http://isbndb.com/api/books.xml?access_key=XXXXXXXX&results=details&index1=isbn&value1='.$rechcode); $xml = new SimpleXMLElement($xmlstr);[/code]
  3. Good luck You've come to the right place for help.
  4. What does dbquery() do if there is an error?
  5. kaoz, you have a misconception about how variables work. This code actually executes the query, storing the result in $adduser $adduser = mysql_query("UPDATE signup SET hotname ='$username'"); Later when you write "$adduser;", that does nothing at all. The query was already executed. So to fix it, you just need to move those mysql_query() calls inside the if/else All 3 queries should go inside, replacing "$increase;", "$adduser;" and "$adduser2"
  6. Try viewing the "page source", from the View menu in your browser. Take a look at the javascript in there. It's possible there is a naming conflict, or perhaps you are using a javascript feature available in firefox but not IE. Variables named "submit", "action", etc etc can cause problems.
  7. Which file says 0kb where and has what text in it? How are you viewing the files?
  8. It's better if you don't remove the extra characters before splitting. Your question "How does it know 2.0 and new should be seperate?" is a good one. The answer is "It doesn't know". Instead, try this: $results = preg_split('|[\[\]() -]+|', $filename);
  9. There's a lot of messy character set issues here.. first thing to do is just to echo $_POST['beer_name'] and see what you get. Make sure that you look at the source of the page rather than the rendered output (go to View -> View Source or the equivalent in your browser). There are many different ways of encoding a character, and if the encodings don't match exactly, the strtr() will not work. I suspect your problem is that the characters have been urlencoded, as in the functions urlencode() and urldecode().
  10. You can't use functions in a switch. Instead, just use if/then/else, which is equivalent to switch.
  11. If you're seeing php code, then your webserver is not treating your script as php. You'll need to alter the configuration (if you control the server) or contact the administrator. You may also be able to fix it by renaming your script, or moving it to a directory where php is enabled.
  12. Are you using php 4 or 5? If 5, then you can use this: http://sg.php.net/manual/en/ref.simplexml.php If 4, then it's messier..
  13. Hmm.. you have an awful lot of "th" there, and not much "tr" or "td". A table should look like this: <table> <thead> <tr> <th>Blah</th> </tr> </thead> <tbody> <tr> <td>123</td> </tr> </tbody> </table> The thead and tbody tags are optional, most people don't use them. "th" means "table header", "tr" means "table row", "td" means "table data"
  14. It opened before because you were ignoring errors. That meant that it wasn't working, but you couldn't see that it wasn't working. It's much better to see the errors so you can fix them. And the error is that no database was selected. Have you implemented ballhogjoni's suggestion of adding "or die("Unable to select database");" to the mysql_select_db() call? Also, can you post the exact error message if possible?
  15. Ok I get it I think a good way to debug will be to store the original base64 encoded string, and the reconstructed string, and print each of them out. Looking at them you should be able to see what's going wrong. IE, compare $filex in the bottom code to the output of base64_encode(), and see what's changed.
  16. Oh.. I didn't realize you were talking about the tutorial Ok, you will need to modify both the $color lines AND the HTML below. For example: echo "<tr> <td width="110" style="background-image: url($row_color)" nowrap> $article_date</td> <td bgcolor="$row_color"> <a href="articles.php?cmd=full_article&article_id=$article_id">$article_title</a></td> </tr>"; [/code] I've now set a background image with CSS, rather than using bgcolor as in the original. Then you can set $color1 = 'style1.jpg' and $color2='style2.jpg' This is untested, so if anything strange happens, post here again
  17. Why don't you check to see if a category was edited, and only replace the producttocategory entries if there was a change? Better still, you can only replace affected producttocategory entries. It is all quite possible to do exactly. If you want, post your code here and we may be able to help you with the SQL.
  18. What system are you using to display your results?
  19. Replace the entire while loop with this: $file = file_get_contents('test.txt'); The while loop was actually putting nonsense into $file, as you were calling file_get_contents() with $i instead of a filename.
  20. I don't understand your question. There is no distinction in either php or c++ between a hex value and an ascii value. What happens when you display the decimal ascii value as hex?
  21. "blank page" often means syntax error. In this case it does (itsmeArry has pointed out the problem). An editor which does php syntax highlighting will save you a lot of grief.
  22. When your script finishes, all memory used by it will be freed. So for most scripts, you will not need unset() Also, variables created and used inside a function will be freed at the end of the function (unless you have made them accessible outside the function, by returning them or putting them in a global variable) Usually I only consider unset() if my script actually does run out of memory.
  23. I think they are having you on. Maybe they saw a lot of accesses to your script and a lot of emails, and put 2+2 together to make 5. Like the others said, mysql injection is the only vulnerability there. But given that it's password protected, even that is unlikely. register_globals is not great either, but you initialize all your variables before use, so that should be no problem. What about your includes? Are they plain html or are they php also?
  24. Oh.. ok i get it. Well, base64 will certainly do it. You could also use str_rot13(), which will use less space (base64 encoding expands data by 33%). You could even use gzip, which will shrink the data, but dealing with binary data is a hassle.
  25. Give us some more details and we can fix it. First, tell us what you want the statement to do Then give us a printout of all the variables involved (using var_dump() if possible), just before the if statement. Then we can tell you why it's not working.
×
×
  • 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.