-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Append to the string, like $select_menu = "<select>"; $select_menu = $select_menu . "<option value=''>Red</option>"; $select_menu .= "<option value=''>Green</option>"; // .= is shorthand for the above $select_menu .= "<option value=''>Blue</option>"; $select_menu .= "</select>";
-
You have to modulo by the number of things, not by the highest number you want to get. So % 9. Using %8 would only give you numbers 0-7, leaving out 8 in the bottom-right corner. +---+---+---+ | 0 | 1 | 2 | +---+---+---+ | 3 | 4 | 5 | +---+---+---+ | 6 | 7 | 8 | +---+---+---+
-
Meaning what? You need to explain things like that because not everybody will read through code looking for bugs when they don't really know what they're looking for. With that said, $i = rand() % 8;Bug $box[1] =='x' && $box[5]=='x' && $box[7] =='x' $box[1] =='o' && $box[5]=='o' && $box[7] =='o'Bug $box[2] =='x' && $box[6]=='x' && $box[8] =='x' $box[2] =='o' && $box[6]=='o' && $box[8] =='o'Bug And your New Game button is a bit wonky with the onclick. And there's an extra
-
FOLLOWLOCATION only works with the Location: HTTP response header. If the pages are redirecting via Javascript or a META refresh or some other mechanism then cURL won't know about it.
-
There are a variety of session-related INI settings. Take a look at your session.cookie_lifetime (lifetime of the session cookie, 0=current session only) and session.gc_maxlifetime (how long before "old" session data can be randomly destroyed).
-
If you keep refreshing the page, well yeah. So only visit the page once. The browser is the one that retrieves the image. Intentionally. If you're using PHP then it won't retrieve the image unless you write code telling it to. Intentionally.
-
Yes.
-
Except for the extra $ in ->$car_list you have it right. Then car_list will be an array containing an array of the cars. Car Object ( [car_list] => Array ( [0] => Array ( [0] => ford [1] => nissan [2] => renault ) ) )If you want to "merge" the arrays together then array_merge them.
-
Right, but with the screenshot you posted there are multiple rows for the same user+day somewhere. If that wasn't the case then there would be only the one row, as you are expecting to get.
-
How can I escape � character from xml/rss?
requinix replied to ayoksus's topic in PHP Coding Help
The question was what RSS feed you're using. Their data is corrupt. You can't really recover from that. However it looks like they meant to use an apostrophe there; figure out the exact value of the bytes there (shown as "�" - bin2hex can help) and do an str_replace() to put in a proper apostrophe.- 4 replies
-
- htmlentities
- illegal chars
-
(and 1 more)
Tagged with:
-
Most things in .htaccess propagate down to subfolders. It should be applying just fine, if it is applying at all. What if you create a .htaccess in one of the subfolders with the same Option -Indexes?
-
How can I escape � character from xml/rss?
requinix replied to ayoksus's topic in PHP Coding Help
What RSS feed?- 4 replies
-
- htmlentities
- illegal chars
-
(and 1 more)
Tagged with:
-
Breadth-first search: every time you find a non-starter dog, append it to an array (as well as the "depth"). Use a while/array_shift() loop to keep pulling stuff off the array (you can't foreach) until you find a starter dog. $dogs = array(current dog); while($dog = array_shift($dogs)) { list($dog, $depth) = $dog; if $dog is a starter dog { return $depth; } else { $dogs[] = array($dog''s mother, $depth + 1); $dogs[] = array($dog''s father, $depth + 1); } }
-
The purpose of using both cookies and sessions vs only cookies?
requinix replied to skyhrg's topic in PHP Coding Help
There's no point to storing the same thing in both cookies and the session, if that's what you're thinking about. You "need" a cookie to use sessions, since that's how PHP knows which session data to get. Cookie data is available for the user to add, edit, and delete at their whim, while session data is not. Cookies are transmitted over the Internet and can thus be eavesdropped upon (if you're not using SSL), sessions are not. -
Use PDO or ODBC. If you're running on Windows I suggest trying PDO via pdo_sqlsrv first, otherwise you have to use ODBC.
-
As you said, through drivers. Probably involving sockets/TCP or pipes, depending on the thing. For SQL Server specifically I think it depends on your connection string.
-
What do you expect to get by grouping these things together? How does one group NULL and "test"? How would you group "one" and "two"? What you're asking in the query doesn't quite make sense - that's why you're not getting the results you want. [edit] I'll jump to the chase. Have you considered GROUP_CONCAT()?
-
Since you're not actually using regular expressions, str_replace() or strtr (with an array) is better. Anyway, the problem is preg_replace() thinks the "$10" in the replacement string is supposed to be a back-reference to the tenth captured substring. Since there isn't one it uses an empty string. $price = addcslashes('$10.99', '$\\');[edit] preg_replace_callback() should be supported but you'd have to use create_function (if you wanted the function inline), which is a really ugly and bug-prone way of doing it - an actual function somewhere would be better. [edit 2] If you're replacing variables, consider doing a preg_replace() or preg_replace_callback() that simply looks for all things that look like variables, checks if the matched variable exists in some master list (you shouldn't just allow any variable at all), and if so replace with the variable's value. Something like function replaceVariables($string, array $variables) { return preg_replace( '/(?<=\$)[a-z_][a-z0-9_]*/ei', 'isset($variables["$0"]) ? $variables["$0"] : "\$$0"', // check that escaping there, might not work $string ); }(which uses /e, yes, but that's not deprecated until 5.5 and using it is easier than preg_replace_callback() with create_function()). If you really wanted to allow for all variables, which I'll say again is a bad idea that you should seriously reconsider, then you can just pass $GLOBALS: $out = replaceVariables($in, $GLOBALS);
-
Setting the pointer of a while do loop to match the current variable
requinix replied to James84's topic in PHP Coding Help
You can't have multiple elements on a page with the same ID. It's supposed to be unique.- 1 reply
-
- while doloops
- pointers
-
(and 2 more)
Tagged with:
-
Ask your hosting provider where you can find the error logs.
-
Have you checked the server error log like the message indicates?
-
You've got a $ on the end of whatever you're using now, right? What are you using? Remove that and replace it with, like, ($|/). Then you can use whatever URL you want so long as it starts with /products/product/713972992/. That fits the first pattern you're considering; say something if you'd rather the second. [edit] On the subject, make sure your product.php figures out what the right URL is supposed to be, compares it to what was actually used, and redirects if the two don't match. That's for SEO: you shouldn't have multiple URLs that work for the same page.