Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. session_start needs to be at the top of every page that uses the $_SESSION array.
  2. If it's a one-time kind of thing then it shouldn't be a problem. If you have the knowhow you could create a quick application in a compiled language (e.g. C++) that would be much faster. PHP isn't really made for something like that, but it will work.
  3. That won't work either. You're looping through an array's values, so all of the values will be set, so nothing will ever be removed. Instead you can do it like this: $arr = array('Bob','2','Ryan','Jane','0','false',''); foreach($arr as $key => $val) { if($val === '') { unset($arr[$key]); } } print_r($arr);
  4. As ignace stated, yes it is possible. For the client you would need to use HTML5 websockets, which aren't implemented, or fully implemented, in most browsers, yet. It's also worth noting that from personal experience I've learned that using PHP for a socket server scales horribly; even at a fairly low level.
  5. $sql="UPDATE product SET title='$item_title', description='$item_description', price='$item_price', ship_to='$item_ship_to', shipping_cost='$item_shipping_cost', international='$item_international', in_location='$item_in_location', in_shipping='$item_in_shipping', country='$item_country', city='$item_city', state='$item_state', sub_id='$item_sub_id', cat_id='$item_cat_id', date=NOW(), exp_date=DATE_ADD(NOW()INTERVAL 59 DAY), relist_date=DATE_ADD(NOW(),INTERVAL 45 DAY), image_upload_box='$item_image_upload', thumb='$item_thumb', artist_email='$artist_email' WHERE id = '{$_GET['id']}'";
  6. Alex

    php explode

    The reason it probably wasn't working before is because you were using single quotes. \n inside of single quotes is taken to be the literal characters "\" and "n" and not a line break character.
  7. That doesn't really help much. From what you're describing it sounds like the problem I outlined above. Are you using both www. and non www. URLs to access parts of the website? It's suggested that you keep it all consistent and force one or the other (you can do this using .htaccess), and this is one reason why.
  8. SELECT * FROM matteroffact ORDER BY id DESC LIMIT 1
  9. $title = "My awesome new event"; echo substr($title, 0, 10) . "..."; substr
  10. Don't forget that those keys should be strings, and as such they should be surrounded in quotes. That code will throw several undefined constant messages, but depending on the level your error_reporting is set to you might not see them. $character = array ("name"=>"Joe", "occupation"=>"Programmer", "age"=>30, "Learned language "=>"Java" );
  11. Can you post the actual code you're using? Here's a few things you should look into: You don't need to set the cookie to expire and set a new one, simply overwrite the value of the previous one Make sure that you're using quotes when you should. Strings should be surrounded in quotes. Make sure that you're not accessing the website through both www. including and www. excluding URLs. Doing such will result in two different cookies to be created.
  12. This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=308967.0
  13. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=308924.0
  14. There are a bunch of JavaScript libraries written specifically for creating games. Here's one that's made for JQuery: http://gamequery.onaluf.org/
  15. Are the bytes signed or unsigned? Edit: Assuming that they're signed, something like this should work: $file = file_get_contents('somefile.map'); $version = current(unpack('i', substr($file, 0, 4))); $position_x = current(unpack('i', substr($file, 4, 4))); // ... $number_of_sectors = current(unpack('s', substr($file, 22, 2))); for($i = 0;$i < $number_of_sectors;++$i) { // read 40 bytes // $bytes = substr($file, $i * 40 + 24, 40); }
  16. Just overwrite the cookie like you were doing it before. Just be aware that the new value will not be available in $_COOKIE until the next request.
  17. It's not really a limitation unless your code logic is flawed. You should rewrite your logic to get around this. Without seeing your code I can't really be more specific. Honestly, from what you've described about your project there are many fundamental flaws. Anyone who gets banned can take the 2 seconds it takes to clear their cookies and they'll be unbanned. For an anonymous posting system banning IPs is a much better solution.
  18. I have a feeling your problem is that you're trying to set the cookie and reading it back in the same request. That won't work because cookies are obtained from the client at the start of the request, and change in the cookies will not be reflected in the $_COOKIE array until the next request.
  19. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=308919.0
  20. SELECT * FROM users WHERE (SELECT COUNT(user_id) FROM todo WHERE user_id = '$user' AND status = 'a' LIMIT 1) > 0
  21. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=308916.0
  22. $sql = "SELECT * FROM table WHERE column IN('" . implode("', '", $_POST['arr_name']) . "')";
  23. Make sure you don't have any whitespace outside of PHP tags, that includes new lines. The error says that the output is started on line 7, so check there.
  24. http://phpjs.org/functions/number_format:481
  25. Fenway's comment was neither unfair nor unwarranted IMO. The fact is that many people who post questions on this forum do not search before they post a question, and when prompted with a response like Fenway's they might be more inclined to attempt to find the solution on their own.
×
×
  • 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.