Jump to content

neoform

Members
  • Posts

    241
  • Joined

  • Last visited

    Never

Everything posted by neoform

  1. you're going to want to not store your data like that in your database.. each number should be it's own row in a table, not comma delimited.
  2. [quote author=kenrbnsn link=topic=111674.msg452711#msg452711 date=1161020142] If you use the function mysql_fetch_assoc() instead, you can then use the [url=http://www.php.net/]extract()[/url] function to do that.  Why don't you just use the array references, which makes the code much more self-commenting. Ken [/quote] I've always wondered how people came to use mysql_fetch_array() instead of mysql_fetch_assoc(), seems like everyone does it..
  3. closer!! haha now it does: [code]?spies? ?ticket?[/code] dagnabbit.
  4. that was actually the first thing i tried.. :( i checked the query and even with both those methods being used, “spies” ‘ticket’ still ends up being the resulting string.. this is perplexing..
  5. unless you've got some heavy sql queries with large databases and joins, it's your host that's slow.
  6. strangely..  that didn't do the trick..  :S i get the impression PHP is somehow encoding the string strangely or maybe the form is..  eitherway, i don't get it. :(
  7. i see the smart quotes.. if i print_r the query it'self then manually run the query, it ends up looking right in the database, but if php runs the query, it's the 3 chars instead of the smart quotes.. 
  8. um, isset($_POST['field_name']) will return true if that form item exists..  not if it's been filled out. You're better checking strlen(trim($_POST['field_name'])) to see how long the entered info is.. if someone types a 0 it'll be 1 char long.
  9. is it a `datetime` timestamp ? [code] date('Y-m-d H:i:s', time() + (365 * 24 *60 * 60)); [/code]
  10. For some reason, when i submit a textfield with this: [quote]“spies” ‘ticket’[/quote] as the value through a POST form, then insert it into a mysql table, this is what ends up in the table: [quote]‘spies’ “ticket”[/quote] To sanitize my forms i use this: [code]function safe_string($str) { if (get_magic_quotes_gpc()) $str = stripslashes($str); //tried this to replace the smart quotes..  no good. :( $search = array('‘','’','“','”');     $replace = array("'","'",'"','"'); $str = ereg_replace($search, $replace, $str); return mysql_real_escape_string(trim($str)); }[/code] Anyone know why this might be happening? My table is using "latin1 -- cp1252 West European" as the charset, and i checked PHP, it's using UTF8..  it's breaking my brain since i've been messing with this for about 10 hours now and I still can't figure it out..
  11. Hi, i'm using PHP's XML functions to process 3 XML feeds. For some reason the 3rd feed (which renders as proper XML in firefox) is throwing the following error WARNING - xml_parse_into_struct() [function.xml-parse-into-struct]: input conversion failed due to input error, bytes 0x9D 0x20 0x2E 0x2E (line: 10) from this code: PHP Code: $parser = xml_parser_create();xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $xml, $tags); xml_parser_free($parser); (line 10 is the "xml_parse_into_struct($parser, $xml, $tags);" line) any ideas? Edit/Delete Message
  12. Thanks :) Works great.
  13. i don't suppose you could throw me an example.. ?  i've been stuck on this query for 3 days now.. :(
  14. my bad, i wasn't even aware there was an explain command..  :( +----+-------------+--------------+------+---------------+-----+---------+-----+-------+------------------------------------------------+ | id | select_type | table        | type | possible_keys | key | key_len | ref | rows  | Extra                                          | +----+-------------+--------------+------+---------------+-----+---------+-----+-------+------------------------------------------------+ |  1 | SIMPLE      | stats_ips    | ALL  | PRIMARY,ip    | NULL| NULL    | NULL|    6 | Using temporary; Using filesort                | |  1 | SIMPLE      | ip_2_country | ALL  | PRIMARY      | NULL| NULL    | NULL| 73952 | Range checked for each record (index map: 0x1) | +----+-------------+--------------+------+---------------+-----+---------+-----+-------+------------------------------------------------+
  15. Well, as much as i'd like to have something like "stats_ips.ip = ip_2_location.ip", that would mean i'd have a record for every possible IP address..  that's like what..  4.2 Billion.. ? :P I'm pretty much stuck using ranges. here's an example of it in use.. SELECT ip, user_id, used_on, country_code2, country_code3, country_name FROM stats_ips INNER JOIN ip_2_country ON ip_from <= ip AND ip_to >= ip ORDER BY used_on DESC LIMIT 0, 20 The output is simply supposed to be a list of ip addresses from the stats_ips table along with related info, like who used it, what country the ip is from and when the ip was last used. i'm looking to make this out be able to be sorted by all 4 fields, which it currently does, but mysql crumbles if i add any amount of ips to the stats_ips table. (btw, my ip_2_location table has about 75,000 rows)..
  16. I wrote this (obviously badly designed) query that matches IP addresses to their associated country (located in my IP2Location table) "SELECT ip, user_id, used_on, country_code2, country_code3, country_name FROM stats_ips INNER JOIN ip_2_country ON ip_to >= ip AND ip_from <= ip ORDER BY ".$_order_by." ".$_order_direction." LIMIT ".(($_page - 1) * PER_PAGE_IPS).", ".PER_PAGE_IPS this is stats_ips: ip (INT UNSIGNED - Primary) user_id (MEDIUMINT - Indexed) used_on (DATETIME - Indexed) this is ip_2_country: ip_from (INT UNSIGNED - Primary) ip_to (INT UNSIGNED - Primary) country_name (CHAR 50 - Indexed) country_code2 (CHAR 2) country_code3 (CHAR 3) One of the reasons i bother with the joining then is becuse i want to be able to order by any of the fields: ip, user_id, used_on, country_name this query worked ok when there was a few rows in stats_ips, but as soon as i added any normal number of rows to it (100,000) it became insanely slow (1000+ seconds). my guess is it's an index problem, (i've always been terrible with index optmizing).
×
×
  • 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.