-
Posts
15,227 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Like, do it for you? How much are you offering?
-
Uh huh. Are those three the only possible patterns? Then you don't need regular expressions: just test for the differences between each one. Like components have a hyphen at the 5th position, spares have one at the 3rd position, and clothing is the odd one out. if ($row["Part_No"][4] == "-") { // component } else if ($row["Part_No"][2] == "-") { // spare } else { // clothing }
-
Error importing excel spreadsheet into mysql ERROR
requinix replied to kdawg2k12's topic in PHP Coding Help
You get what error? -
I don't suppose this thing you're running has a daemon mode, right?
-
Yes, and for that reason. No. The first reason is that the values might contain quotes that will mess up your SQL queries. You need to protect against that happening, whether it's accidental or not. The second reason is a blanket rule: you cannot trust anything that comes from a browser. Period. If they're an administrator it doesn't matter. If you have JavaScript validation or sanitization it doesn't matter. It's all equally untrustworthy. If I understand you right, only do it the one time. mysql_real_escape_string() give you an altered string that's safe for SQL queries - it doesn't do any hidden magic like mark a variable as special or whatever. If you did it a second time on the new string then you'd be doubly-escaping it. Yeah, that's fine. Vast majority of scripts don't need two database connections open at once so it's rarely a problem.
-
This topic has been shift+dragged to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=353982.0
-
How about this structure? orders order_id | ... ---------+---- 1 | 2 | 3 | products product_id | color | size | ... -----------+-------+--------+---- 1 | blue | small | 2 | blue | medium | 3 | blue | large | 4 | pink | small | 5 | pink | medium | 6 | pink | large | orders_products order_id | product_id | quantity | ... ---------+------------+----------+---- 1 | 1 | 3 | 1 | 3 | 3 | 2 | 2 | 5 | 2 | 5 | 5 | That's a fairly typical setup for this kind of thing.
-
Now that you're in the Regex forum, take a look at some of the stickies at the top of the thread listing. They should be able answer your questions.
-
This topic has been... uh... whatsit... moved? to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=353911.0
-
Semicolons are used to terminate queries in situations where (a) it's not always clear when one is finished, and (b) when there could be more than one query provided. Neither is true with what you provide to mysql_query(). Whatever the reason, MySQL themselves have said explicitly that you should not include it: http://dev.mysql.com/doc/refman/5.5/en/mysql-query.html
-
1. You need quotes around the title string. 2. You need to use mysql_real_escape_string on that title first. 3. Don't end your queries with semicolons. This is not the circumstance when they're supposed to be used. "INSERT INTO posts (title) VALUES ('" . mysql_real_escape_string($_POST['title']) . "')"
-
Two methods. The one I prefer is to use some JOINs SELECT c.content_id, c.content_title, c.content_body, co_p.value AS price, co_w.value AS weight, co_s.value AS sale FROM content c LEFT JOIN content_options co_p ON c.content_id = co_p.content_id AND co_p.option = "price" LEFT JOIN content_options co_w ON c.content_id = co_w.content_id AND co_w.option = "weight" LEFT JOIN content_options co_s ON c.content_id = co_s.content_id AND co_s.option = "sale" (outer joins, just in case the price/weight/sale value is missing) and the other is subqueries SELECT c.content_id, c.content_title, c.content_body, (SELECT value FROM content_options co WHERE co.content_id = c.content_id AND co.option = "price") AS price, (SELECT value FROM content_options co WHERE co.content_id = c.content_id AND co.option = "weight") AS weight, (SELECT value FROM content_options co WHERE co.content_id = c.content_id AND co.option = "sale") AS sale, FROM content c
-
If you want preg_replace() to treat a string as PHP code to evaluate then you need to use the /e flag in the search expression. Then make the replacement string be the code you want executed. Also, you really shouldn't be HTML encoding anything until it's about to be displayed. However that's the general case: in your situation you should have two separate fields in your database table for the post text. One of them is the original text so you don't have to reverse-engineer it, and the other is the HTML-ready text so you don't have to parse BBCode and such every time you want to display it.
-
Problem with dns_get_record() - shows only 4 Name Servers
requinix replied to ankur0101's topic in PHP Coding Help
Because they know something we don't: that there are two different lookup results, for whatever reason, and can gather the results from both into one report. -
Problem with dns_get_record() - shows only 4 Name Servers
requinix replied to ankur0101's topic in PHP Coding Help
Well, a second lookup gives me Non-authoritative answer: domain-whois-lookup.com MX preference = 0, mail exchanger = domain-whois-lookup.com domain-whois-lookup.com primary name server = ns1.linkwayhosting.com responsible mail addr = webmaster.linkwayhosting.com serial = 2012020501 refresh = 86400 (1 day) retry = 7200 (2 hours) expire = 3600000 (41 days 16 hours) default TTL = 86400 (1 day) domain-whois-lookup.com nameserver = ns1.linkwayhosting.com domain-whois-lookup.com nameserver = ns2.linkwayhosting.com domain-whois-lookup.com internet address = 204.197.241.82 It alternates between the two every time. I don't know enough about the system to tell you why it's doing that or how to tell that it does. -
Problem with dns_get_record() - shows only 4 Name Servers
requinix replied to ankur0101's topic in PHP Coding Help
Doing a lookup from home only shows me the four awsdns nameservers - not six. Non-authoritative answer: domain-whois-lookup.com nameserver = ns-146.awsdns-18.com domain-whois-lookup.com nameserver = ns-778.awsdns-33.net domain-whois-lookup.com nameserver = ns-1523.awsdns-62.org domain-whois-lookup.com nameserver = ns-1613.awsdns-09.co.uk domain-whois-lookup.com primary name server = ns-1613.awsdns-09.co.uk responsible mail addr = awsdns-hostmaster.amazon.com serial = 1 refresh = 7200 (2 hours) retry = 900 (15 mins) expire = 1209600 (14 days) default TTL = 86400 (1 day) domain-whois-lookup.com internet address = 204.197.241.82 -
The expression needs ^ and $ anchors at the beginning and end, respectively.
-
One thing that hasn't been pointed out yet: $_FILES[foo]["type"] is not secure because it is provided by the browser, not by PHP. You need to figure the type out by yourself (like with getimagesize()).
-
SELECT player_id FROM x WHERE -- "all the nt_caps=0" also means "there aren't any nt_caps!=0" player_id NOT IN ( -- these are players to *exclude* SELECT player_id FROM x WHERE nt_caps != 0 -- however not all nt_caps!=0 are bad - only the ones that aren't nat=68 too AND nat != 68 )
-
What's your exact code and are you sure that the stuff is real XML?
-
It'd be whatever generates the content. Like PHP. First item it prints has one color. Next one has the other. Next one has the first. And so on.
-
Are you talking about alternating coloring? [edit] There's a pure CSS way but it isn't supported everywhere yet. Otherwise whatever code generates the list also decides the coloring for each item in it.
-
Your second example is screwed up in a few ways. Did anybody notice that SimpleXMLElement can take a URL as an argument? Or that the third argument is only true if the $data is a URL? $url = "http://www.myurl.com/api?user=$userid"; $xml = new SimpleXMLElement($url, null, true);
-
.header img selects any IMG that's a descendant of any class=header element. img.header selects any IMG with a class=header. You need to find yourself a tutorial or book on CSS.
-
RewriteRule doesn't include the query string when it matches URLs. RewriteEngine On RewriteCond %{QUERY_STRING} ^search_KEYWORD=([a-z]+)&search_RANGE=([a-z]+)&o=([0-9]+)&search=[0-9]+$ [NC] RewriteRule ^/09search_results.php$ /%2/%1/%3 [NC, L]