Jump to content

irken

Members
  • Posts

    94
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.iblob.dk/

Profile Information

  • Gender
    Not Telling

irken's Achievements

Member

Member (2/5)

0

Reputation

  1. Yes. But isn't that a bit weird.. why is something enclosed in pings treatet as a numeric? Maybe I got the whole what's a string and what's not wrong : ). You learn every day - thanks! Edit: Perhaps it's safe to use is_int() on the $var instead? If you're just checking for 12345.. Edit again again: Oh, I just read the manual. "To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric()." - that makes sense.
  2. Well. Doing, as per Barand's snippet: $numer = '12345678'; if (!is_numeric($number)) echo "Not numeric"; Does actually not output "Not nummeric". I thought that ' (pings) got treatet as a string?
  3. Hello. I have the following piece of code: if (isset($_GET['q'])) { $params = explode('/', trim(stripslashes($_GET['q']))); @list($plugin, $function) = $params; # index.php?q=test/add # index.php?q=test/del if (isset($plugin) && isset($function)) { $plugin_path = './plugins/' . strtolower($plugin) . '/' . strtolower($function) . '.php'; if (is_file($plugin_path)) { @include_once $plugin_path; exit; } } # index.php?q=test if (isset($plugin) && !isset($function)) { $plugin_path = './plugins/' . strtolower($plugin) . '.php'; if (is_file($plugin_path)) { @include_once $plugin_path; exit; } } } else { // Show front page.. } What this does is allow me to write for example: index.php?q=test - to include the file located at ./plugins/test.php index.php?q=test/add - to include the file located at ./plugins/test/add.php And so forth. I'm looking for a more dynamic way of doing this. What if I need to have yet another parameter for articles perhaps. index.php?q=article/view/01 That would require me to make yet another if expression and expand the list statement: @list($plugin, $function) = $params; if (isset($plugin) && isset($function) && isset($article_id)) { .. } Is there a way around this? Perhaps even a better way. It's not very dynamic if I have to change my functions each time I need to add a feature and/or module and would result in like 50 if checks. Thanks for reading.
  4. Ah, I should've noticed that. The array should be: ('testvar' => 'something elseeee') rather than ('testvar', 'something elseeee') Thanks, now I can finally get on with it : ).
  5. Hello. I was attemping to make an array of configuration variables for Smarty when I ran into this little problem. Here's some example code first of all: <?php class Testclass { var $testvar = 'something'; } $test = new Testclass; echo "before foreach: $test->testvar\n"; # echos 'something' $arr = array('testvar', 'something elseeeee'); foreach ($arr as $key => $value) { $test->$key = $value; # set $test->[variable] to $value } echo "after foreach: $test->testvar\n"; #echos 'something' Problem. This outputs "something" in both places, while I expected it to echo "something elseeee" after the foreach is done. Setting $test->testvar manually and outputting it workes fine, but breaks in the foreach. To me this seems weird, but might just be how PHP workes. If that's the case, how do I work around this? Thanks for reading.
  6. Hello. Correct me if I'm wrong, but isn't a persistent mysql connection supposed to return the previous connection resource once I do mysql_pconnect() again, with the same parameters? Here's my very simple test class.. <?php class Mysql { var $hostname = 'localhost'; var $username = 'gateway'; var $password = ''; var $database = 'somedatabase'; var $connection = NULL; public function __construct() { } public function connect() { if (!$this->connection) { $this->connection = mysql_pconnect($this->hostname, $this->username, $this->password); mysql_select_db($this->database); return $this->connection; } // resource exists ? return $this->connection; } } ?> And some test script <?php include('mysql.php'); $myMysql = new Mysql; $myMysql->connect(); ?> Acording to mysql's SHOW processlist the result is this: mysql> show processlist; +-----+---------+-----------+----------------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +-----+---------+-----------+----------------+---------+------+-------+------------------+ | 151 | root | localhost | NULL | Query | 0 | NULL | show processlist | | 159 | gateway | localhost | somedatabase | Sleep | 984 | | NULL | | 160 | gateway | localhost | somedatabase | Sleep | 963 | | NULL | | 161 | gateway | localhost | somedatabase | Sleep | 809 | | NULL | | 162 | gateway | localhost | somedatabase | Sleep | 3 | | NULL | +-----+---------+-----------+----------------+---------+------+-------+------------------+ 5 rows in set (0.00 sec) As you can see there are 4 connections? This is from refreshing the test.php script 4 times. Am I to undertand that it's pooling up connections and when it reaches max, it will return one of them to the PHP script? Thanks for reading.
  7. Please provide a solution for future reference .
  8. The only reason to do anything along the lines of "obfuscating" your Javascript could, is to decrease size. You will always be able to see the source, your browser can. I pack my scripts using http://dean.edwards.name/packer/ - it makes it somewhat "hard" for the average user to look through it (could just "unpack") - but then again, the average user has no reason to look at my code - so I do it to decrease size as a priority.
  9. Not sure I understand fully, but then again I diden't read it all ;s. Try using a POST request instead, it seems as if it's caching the information somehow, but then not doing the request again maybe because the page is already cached, or something. Always good practise to use POST requests, as nothing will get cached (in IE).
  10. Frameworks are great, but weather or not you should use one is up to you, and what you can do. Couple of posts at the bottom of this thread which might interrest you: http://www.phpfreaks.com/forums/index.php/topic,119739.0.html
  11. [quote author=Darkstar link=topic=124453.msg516199#msg516199 date=1170089360] as it turns out, IE has another flaw when it comes to AJAX.  it refuses to fetch the actual content on the fetched page but will instead use the last cache of it.  I searched google for a minute or two and came up with the following: [code]setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");[/code] i just inserted it into: [code]  xmlHttp.open("GET",urlFetch,true);   xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");   xmlHttp.send(null);[/code] and voila!  no more cache [/quote] That's not an actual flaw. IE will cache all GET requests, AJAX or no ajax. If you use POST instead (even if you don't have anything that requires POST), the page should not get cached.
  12. Ok. Well, then there's something to work with atleast. What exactly are you trying to archieve? What does the HTMLDivElement object contain? Kind of weird because HTMLDivElement inherits functions from HTMLElement, which contains the getElementById function, yet it errors saying it doesn't.
  13. Try doing an alert on obj.firstChild in your htmlDom function.. does it return blank? If it does, then the property getElementById is going to error. Error: wootCache.getElementById is not a function It looks as if it's returning a blank object.
  14. One idea would be to comment out everything that's not needed for the vhost to run. You don't need to specifiy error logs for example. Comment all that out, write only things like: ServerAdmin DocumentRoot ServerName ScriptAlias Does that work at all? If it does, start by appending each of your other lines until it errors.
  15. [quote author=acp26b link=topic=124447.msg515614#msg515614 date=1170014715] Always got to one up everyone huh jesirose? :P [/quote] It comes with the title: [b]PHPFreaks Recommended - Proficient[/b]  ;D
×
×
  • 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.