Jump to content

The Little Guy

Members
  • Posts

    6,675
  • Joined

  • Last visited

Posts posted by The Little Guy

  1. This worked for me:

     

    <?php
    $blacklistArr = array("email@email.com", "email2@email.com", "email3@email.com", "@gmail.com");
    function isBL($e){
    global $blacklistArr;
    $isBlackListed = false;
    foreach($blacklistArr as $email){
    	$email = preg_quote($email);
    	if(preg_match("/$email/i", $e)){
    		$isBlackListed = true;
    		break;
    	}
    }
    return $isBlackListed;
    }
    
    $tests = array("email@email.com", "myemail@gmail.com", "email23@email.com", "email2@email.com", "mike@yahoo.com");
    foreach($tests as $email){
    echo "$email: ";
    var_dump(isBL($email));
    echo "<br>";
    }
    ?>

  2. Why doesn't my image load() fire?

     

    The image loads, but the function doesn't fire. This part works: $("#main").fadeIn(3000);

     

    <script type="text/javascript">
    $(window).load(function(){
    	$("#main").fadeIn(3000);
    	$("img#ximage").load(function(){
    		$(this).fadeIn("fast");
    	});
    });
    </script>

     

    <body>
    <div id="main" style="display: none;">
    	<div id="X"><img src="/images/x.png" alt="X" id="ximage" style="display: none;" /></div>
    	<p>Some text goes here</p>
    </div>
    </body>

  3. Try this:

     

    $q = "SELECT song_id, song_title, added_date, datediff(now() - interval 7 day, added_date) as date,  (downloaded / datediff(now() - interval 7 day, added_date)) as average FROM songs ORDER BY downloaded DESC";

  4. I actually take back my previous post, and think you should do this:

     

    set @m:=0;
    select * from (SELECT member_id, (v1+v2+v3) AS total, @m:=@m+1 AS rank from members order by total desc) as tbl where member_id = 2;

  5. I have 2 indexes on the table and ~130 row in it.

    +---------------+------------------+------+-----+-------------------+----------------+
    | Field         | Type             | Null | Key | Default           | Extra          |
    +---------------+------------------+------+-----+-------------------+----------------+
    | search_id     | int(10) unsigned | NO   | PRI | NULL              | auto_increment |
    | domain_id     | int(10) unsigned | NO   | MUL | NULL              |                |
    | ip            | int(10) unsigned | YES  |     | NULL              |                |
    | search_string | char(50)         | NO   |     | NULL              |                |
    | search_date   | timestamp        | NO   |     | CURRENT_TIMESTAMP |                |
    +---------------+------------------+------+-----+-------------------+----------------+

     

    +----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
    | Table    | Non_unique | Key_name  | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
    +----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
    | searches |          0 | PRIMARY   |            1 | search_id   | A         |         134 |     NULL | NULL   |      | BTREE      |         |               |
    | searches |          1 | domain_id |            1 | domain_id   | A         |           2 |     NULL | NULL   |      | BTREE      |         |               |
    +----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

  6. What would cause this line:

    insert into searches (domain_id, ip, search_string) values ($domain_id, inet_aton('$ip'), '$string');

     

    To take 0.06 seconds to run? It is only run one time. That takes up half the time it takes my 8 other queries to run (inserts and selects).

  7. I am trying to add a primary key on a temporary table, but it isn't working.

     

    Here are the following queries:

    create temporary table rt_results (document_id int, weight int, primary key(document_id));
    insert into rt_results values(1, 123);
    
    explain select dom.domain_id, domain, url, title, content from
    rt_results rt
    left join documents doc on (rt.document_id = doc.document_id)
    left join urls u on(doc.document_id = u.document_id)
    left join domains dom on(doc.domain_id = dom.domain_id)
    order by rt.weight desc;

     

     

    And here is the explain result:

    +----+-------------+-------+--------+---------------+-------------+---------+------------------------+------+----------------+
    | id | select_type | table | type   | possible_keys | key         | key_len | ref                    | rows | Extra          |
    +----+-------------+-------+--------+---------------+-------------+---------+------------------------+------+----------------+
    |  1 | SIMPLE      | rt    | ALL    | NULL          | NULL        | NULL    | NULL                   |    1 | Using filesort |
    |  1 | SIMPLE      | doc   | eq_ref | PRIMARY       | PRIMARY     | 4       | search.rt.document_id  |    1 |                |
    |  1 | SIMPLE      | u     | ref    | document_id   | document_id | 4       | search.doc.document_id |    1 |                |
    |  1 | SIMPLE      | dom   | eq_ref | PRIMARY       | PRIMARY     | 4       | search.doc.domain_id   |    1 |                |
    +----+-------------+-------+--------+---------------+-------------+---------+------------------------+------+----------------+
    4 rows in set (0.00 sec)

     

    Why does it say "NULL" for the key? I added a primary key to rt.document_id so shouldn't it use it? It seem logical that it would to me.

     

    Thanks!

  8. I am doing this:

    $fields = array(
    "code" => $this->code,
    "secret" => $this->secret,
    "domain" => $_SERVER['HTTP_HOST'],
    );
    $this->ch = curl_init();
    curl_setopt($this->ch, CURLOPT_URL, "http://weblyize.com/API/v1");
    curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($this->ch, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($this->ch, CURLOPT_POSTFIELDS, $fields);
    curl_setopt($this->ch, CURLOPT_POST, true);
    $opt = curl_exec($this->ch);
    return $opt;

     

    But the post fields are not being passed for some reason, and I can't figure out why. I do a print_r($_POST); on the url above, and it is empty.

     

    Do you see anything wrong with my curl?

     

    Here is the page:

    http://phpsnips.com/search/doSearch.php

  9. js and php are just as comparable:

     

    - Both are scripting languages; Both are modes of transportation

    - One works with the file system one doesn't; One poops one doesn't

    - One requires a server one doesn't; One is fast one is slow

    - One can do ajax one can't; One needs an oil change one doesn't

    - One same code works in all browsers other doesn't; One has built in satellite radio one doesn't

    - Both are fun to program; Both die

    - Both have similar functionality (Math, Strings, Classes); Both need food to keep it moving

    - One runs in the browser one doesn't; One has hooves one doesn't

    - One is as fast as the browser it is run in one is as fast as the server it is run on; One needs to be brushed one doesn't

     

     

    See lots of similarities, and differences.

×
×
  • 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.