Jump to content

dreamwest

Members
  • Posts

    1,223
  • Joined

  • Last visited

    Never

Posts posted by dreamwest

  1. Im trying to get this small javascript to work

     

      
    <script>
    
    var loc = document.getElementById("test");
      
      if(loc == true){
      
      document.write("check");
      return; 
      }
    </script>
    
    <div id="test"></div>
      

     

    So basically when the page loads and if theres a div called "test" the javascropt will write "check". But ive still got it wrong .....

  2. I need to set an option to direct the php script to the right table of the database based a div id

     

    <script>
    
    var xmlhttp
    
    function showHint(str)
    {
    if (str.length==0)
      {
      document.getElementById("movie").innerHTML="";
      return;
      }
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
      {
      alert ("Your browser does not support XMLHTTP!");
      return;
      }
    var url="2.php";
    url=url+"?"+str;
    xmlhttp.onreadystatechange=stateChanged;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
    }
    
    function stateChanged()
    {
    if (xmlhttp.readyState==4)
      {
      document.getElementById("movie").innerHTML=xmlhttp.responseText;
      }
    }
    
    function GetXmlHttpObject()
    {
    if (window.XMLHttpRequest)
      {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      return new XMLHttpRequest();
      }
    if (window.ActiveXObject)
      {
      // code for IE6, IE5
      return new ActiveXObject("Microsoft.XMLHTTP");
      }
    return null;
    }</script>
    
    
    <div style='position:absolute; top:25px; left:0px;' id="movie"></div>
    
    

     

    Basically i need to add a type to this line based on the div name :

     

    so if the div id is movie:

    <div style='position:absolute; top:25px; left:0px;' id="movie"></div>

     

    The javascript will look like this:

    var url="2.php";

    url=url+"?type=movie"+str;

     

    OR if the div id is tv:

    <div style='position:absolute; top:25px; left:0px;' id="tv"></div>

     

    The javascript will look like this:

    var url="2.php";

    url=url+"?type=tv"+str;

     

  3. No wonder its timing out you 12,000 rows in one hit.

     

    2 solutions:

    one is to query 20 rows at a time and use LIMIT 1,20,

     

    "SELECT * from table LIMIT 1,20"

     

    the second is to add a tmp field in the table and make it tinyint, then just select and update rows where tmp ='0'

     

    "SELECT * from table WHERE `tmp`='0' LIMIT 1,20"

     

    after successful query update the tmp field to 1

  4. Hi,

     

    I have a problem with URL  RewriteRule with my .htaccess file. ie. I need to redirect to a Url containing the special character "#" (Example:www.example.com/#id) from an html page. When "#" is given direcltly , it is redirected to

    www.example.com/%23id and resulting "a page not found" error page.

    The rewrite rule I used is

    Options +FollowSymLinks

    RewriteRule ^test.html$ /#test/ [R=301,L]

    Please anyone help. Thanks in advance.

     

    Your "real" url wont exist anywhere. So you saying you have a directory like this?

     

    http://site.com/#test/

  5. <?php

    header('Location: http://www.yoursite.com/');

    ?>

     

    Taken from

    -

    http://php.net/manual/en/function.header.php

     

    Thats ok if your headers havent been sent, othwise youll need javascript:

     

    function redirect( $url ){
    if (! headers_sent( ) ){
    
    header( "Location: ".$url );
    exit( 0 );
    }
    echo "<script language=Javascript>document.location.href='".$url."';</script>";
    exit( 0 );
    } 
    
    redirect('http://www.yoursite.com/'); //redirect to any url
    

  6. $results =  mysql_query("SELECT `Name` FROM `CES` WHERE `Name` !='' ");
    
    while($row = mysql_fetch_assoc($results)) {
    
    echo "<option value='{$row['Server']}'> {$row['NAME']}</option>";
    
    }
    
    

     

    This code certainly can not work, because you do not specify that the query return a column named 'Server' in your query.  This might help -- without knowing the structure of your CES table, it's not possible to say for sure.

     

    $results =  mysql_query("SELECT `Name`, `Server` FROM `CES` WHERE `Name` !='' ");
    

     

    My bad. Im doing 10 things at once ATM.

     

    I would add SELECT * if you queries are below 10,000 requests per day

  7. Thanks.

     

    Problem is it doesnt reduce the amount of code for the query/ies and ill still have 3 queries. I was trying to reduce it to one combined query thus creating less code, easier to remember & less cluttered apps - it may be possible with subqueries, ill have to brush up on that

     

     

  8. I recently had the same problem, it was a combination of google hitting bad queries i had made ages ago like 150,000 times a day.

     

    I removed order by rand() with the altenate FLOOR(), indexed all query joins , removed live count(*)  and just had totals coming from an updated table.

     

    First place to look is bots hitting your database driven pages through awstats

  9. I had to remove rand from my queries because my database is over 3 million rows and it was serioulsly affecting the server

     

    Is it possible to compress this alternate rand query into one line aka one mysql_query():

     

    
    $offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM `video` ");
    $offset_row = mysql_fetch_object( $offset_result ); 
    $offset = $offset_row->offset;
    $result3 = mysql_query( " SELECT * FROM `video` WHERE approve='1' and `show`='1'  LIMIT $offset, 10 " );
    
    

  10. I saw a movie back in 1993 and i cant what it was, it must have been made between 1970 and 1993.

     

    Description:

    The plot revolves around the sun "super flaring" thus killing every living thing on earth - except those who actually died the moment the sun flared, there are three ppl 2 guys one gal they all eventually meet up through the course of the film. One of the guys discovers what happened and you see him observing the sun and trying to warn the other 2 who couldnt care less.  Anyway in the end the sun is starting to flare again so he kills himself in a mack truck....thus surviving the flare at that instant.

     

    Thats all i can remember, ive been searching for ages for this. If you know this title -  let me know and ill luv u long time :P

  11. Im trying to check if a file is a duplicate based on the md5 of the file, I have this so far but im not sure which way to go with it

     

    
    $file = $_FILES["file"]["name"];
    $md_file = md5_file($file);
    $dir = getcwd();
    
    if(file_exists($dir.$md_file){
    
    echo "Image already exists. Please upload a different image.";
    }
    
    

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