Jump to content

Nuv

Members
  • Posts

    212
  • Joined

  • Last visited

Posts posted by Nuv

  1. I have a database something like mentioned below. Please note that this is not the complete table structure. Only the relevant is shown.

     

    CREATE TABLE IF NOT EXISTS `student` (
     `id` int(13) NOT NULL AUTO_INCREMENT,
     `title` varchar(3) NOT NULL,
     `firstname` varchar(30) NOT NULL,
     `middlename` varchar(30) NOT NULL,
     `lastname` varchar(30) NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
    

     

     

    I'm collecting the name in 3 parts, Firstname , Middlename and Lastname . Now while searching for a name i'm trying to CONCAT all the 3 parts and then search.

     

    $sql_name = mysqli_query($con, "SELECT * FROM `student` WHERE CONCAT( firstname,' ', middlename,' ', lastname ) Like '".$search."%'  LIMIT ".$start.", ".$limit."") or die("Error: ".mysqli_error($con));;
    

     

     

    I'm only wondering if there is a better and faster way to achieve this ?

    While searching over the web i saw some people using the 'difference' between name and search string and displaying it in descending order, however they weren't using MySql .

  2. When i am trying to do this simple math, php gives me rounded off result.

     

    $i = 44061410;   
    $get_id = (2*$i + 76561197960265730) - 2;
    

     

    Expected Result - 76561198048388548

     

    Result i am getting from php - 7.65611980484E+16

     

     

    How can i see expected result ?

     

    Thankyou

  3. I want that my text container's width should be static (100px). However, when i put width:100px; in my #content the main container (with orange color) changes its width and not the text. The text should come to the next line after exceeding 100 px

     

    My HTML

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>CMS - BLOG </title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" href="main.css" type="text/css">
    
    </head>
    <body>
    
    
    <div class = "container">
    
    <div class="content-container">
    
    <span id="content">
    
    Something Something Something Something Something Something Something Something Something Something Something<br>
    
    </span>
    
    </div>
    
    </div>
    
    
    </body>
    </html>

     

    Main.css

     

    .container {
    float:left;
    margin:20px;
    background:rgba(227,162,11,0.7);
    
    }
    
    .content-container {
    
    margin:20px;
    
    }
    
    #content {
    
    width:100px;
    font-size: 18px;
    color: #333333;
    
    }

  4. Mate, I think you are seeing something i'm not able to. What i'm seeing is pagination happens using the same js function and i'm not able to traverse through pages using Php. I thought about doing the same you suggested but i wasn't able to, thus i posted here  :-[

     

      <a id="next-n-start"
    href="javascript:void(0);" onclick="reloadSection('#start=10', 'ps-sellers');"
    onmousedown="return logClick('\x2Fproducts\x2Fcatalog?hl=de\x26q=4242002690209\x26cid=2594634728159287170\x26cpo=1\x26sa=N\x26start=10', 'cc', 'Overview', 'tabless', '2594634728159287170', 'ps-sellers-frame_Weiter \x26raquo\x3B')"
    >Weiter »</a>

     

    Little more help would be appreciated.

     

     

     

     

  5. Code im using

     

    <?php
      
      $get_EAN = '4242002690209';
      $url = "http://www.google.de/search?hl=de&tbm=shop&q=".$get_EAN."&oq=".$get_EAN;
       
      $ch = curl_init();
         
      curl_setopt ($ch, CURLOPT_URL, $url);
      curl_setopt ($ch, CURLOPT_USERAGENT, "spider");
      curl_setopt ($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
        
      $get_product = curl_exec ($ch);
      curl_close ($ch);
      
        
      preg_match_all('~<div class="pslimain"><h3 class="r"><a href="(.*?)"~s', $get_product, $get_price); 
      
      if(preg_match('#cid=(.*)#', $get_price[1][0], $r)) {
           $get_cid = trim($r[1]);       
       }
      
      $url = "http://www.google.de/products/catalog?hl=de&q=4242002690209&cid=".$get_cid;
      
      $ch = curl_init();
         
      curl_setopt ($ch, CURLOPT_URL, $url);
      curl_setopt ($ch, CURLOPT_USERAGENT, "spider");
      curl_setopt ($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
        
      $list_price = curl_exec ($ch);
      curl_close ($ch);
      
      print_r($get_price[1][0]);
      print_r($get_product);
      print_r($list_price);
      
      
    ?>

  6. I'm trying to scrape data from google.de/shopping.

     

    Consider the following URL

     

    http://www.google.de/products/catalog?hl=de&q=4242002690209&cid=2594634728159287170

     

    I need to sort this product list with 'Endpreis' (if you don't translate German to English). I need the lowest of all. Clicking it on a normal browser gets the job done as it does this using javascript. However while scraping using Php it doesn't sort it.

     

    Obviously, I need to check the javascript involved and i did. Here is my analysis. When i check the javascript document named ps-js.js i get the function logClick.

     

    D("logClick",function(a,b,c,d,e,f){document.images&&((new Image).src=gb("/products/log","?ptab=pp_click","&pp_exp=",d,"&pp_vert=",b,"&pp_sec=",c,"&pp_lk=",f,"&cid=",e,"&pp_durl=",a));return j})

     

    Corresponding html for it is

     

    href="javascript:void(0);" onclick="reloadSection('#scoring=tps', 'ps-sellers');"
    onmousedown="return logClick('\x2Fproducts\x2Fcatalog?hl=de\x26q=4242002690209\x26cid=2594634728159287170\x26scoring=tps', 'cc', 'Overview', 'tabless', '2594634728159287170', 'Endpreis')"
    class="">Endpreis</a>

     

    When i input the value

     

    http://www.google.de/products/log?ptab=pp_click&pp_exp=tabless&pp_vert=cc&pp_sec=Overview&pp_lk=Endpreis&cid=2594634728159287170

     

    Nothing happens.

     

    Any workaround or help to get the lowest Endpreis in the product list would be really appreciated.

     

    Thankyou

  7. Hey,

     

    I'm trying to scrape google.de/shopping . However I'm having following problem.

     

    Please check -

     

    view-source:http://www.google.de/search?hl=de&tbm=shop&q=4242002690209&oq=4242002690209

     

    The url for the product is something like

     

    <a href="/products/catalog?hl=de&q=4242002690209&um=1&ie=UTF-8&tbm=shop&cid=2594634728159287170&sa=X&ei=5etEUJOlNI3zrQfuh4HADQ&ved=0CFYQ8wIwAA">Bosch MCM 42024 Red Diamond/Silber, Styline K?chenmaschine</a>

     

    And the url of the product i'm getting from my code is

     

    /products/catalog?hl=de&q=4242002690209&um=1&ie=UTF-8&tbm=shop&cid=2594634728159287170

     

     

    Why is it that "&sa=X&ei=5etEUJOlNI3zrQfuh4HADQ&ved=0CFYQ8wIwAA" part is missing when im trying to scrape the url and where is it coming from ?

     

    P.S - In "&sa=X&ei=5etEUJOlNI3zrQfuh4HADQ&ved=0CFYQ8wIwAA" ei value changes everytime so try searching "Bosch MCM 42024 Red Diamond/Silber, Styline K?chenmaschine" while checking the source code.

     

    Code im using -

     

    <?php
      $get_EAN = '4242002690209';
      $url = "http://www.google.de/search?hl=de&tbm=shop&q=".$get_EAN."&oq=".$get_EAN;
      
      $ch = curl_init();
         
      curl_setopt ($ch, CURLOPT_URL, $url);
      curl_setopt ($ch, CURLOPT_USERAGENT, "msn");
      curl_setopt ($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
        
      $get_product = curl_exec ($ch);
      curl_close ($ch);
        
      preg_match_all('~<div class="pslimain"><h3 class="r"><a href="(.*?)"~s', $get_product, $get_price); 
      
      $url = "http://www.google.de".$get_price[1][0];
      
      $ch = curl_init();
         
      curl_setopt ($ch, CURLOPT_URL, $url);
      curl_setopt ($ch, CURLOPT_USERAGENT, "msn");
      curl_setopt ($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
        
      $list_price = curl_exec ($ch);
      curl_close ($ch);
      
      print_r($get_price[1][0]);
      //print_r($get_product);
      //print_r($list_price);
      
      
    ?>

  8. Why won't my curl code not give any output, however if i use $data = file_get_contents($url); and var_dump it, i get the result. Any guesses ? :confused: . Thankyou in advance.

     

    cURL code :

     

       $get_EAN = '5999883271933';
       $ch = curl_init();
       $url = "http://www.guAAAenstiger.de/Katalog/Suche/".$get_EAN.".html"; // Remove the 3 Capital AAA's in the url, doing this to avoid indexing with that site url
          
       curl_setopt ($ch, CURLOPT_URL, $url);
       curl_setopt ($ch, CURLOPT_USERAGENT, 'spider');
       curl_setopt ($ch, CURLOPT_HEADER, 0);
       curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
       curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
           
       $get_choice = curl_exec ($ch);
       curl_close ($ch);
       
       echo "<pre>";
       var_dump($get_choice);
       echo "</pre>";

     

    Output:

     

    string(0) ""
    
    

  9. Hey,

     

    When my backup.php is executed, i need my interrupt.php to start too and should run at an interval of 15mins, and before completion of my backup.php my interrupt.php should stop. Something like

     

    <?php
    //Start interrupt.php again and again at an interval of 15 mins
    
    // Rest of my code here
    
    //Stop interrupt.php
    
    ?>

     

    Though i have no clue how to do that :shrug:. Any leads ? Is there any function for that ?

     

    Thankyou. 

  10. It may work in your query due to the fact that you enclosed datetime in backticks, and the OP did not. Without the backticks it may be ambiguous, so they could be needed in this instance.

     

    Funny after using "SELECT * FROM logbook ORDER BY `datetime` ASC" , i get

     

    sqlasc.PNG

     

    And after using "SELECT * FROM logbook ORDER BY `datetime` DESC", i get

     

    sqldesc.PNG

     

    Why am i getting unexpected results ?  :'(

    Although, time is perfect when i use 'DESC' but not the dates. I really wanted to sort this only with SQL and not using Php.

  11. Not working. I'm getting the same result. Here is my full code i am using with full logbook.sql dump.

     

      <?php
                                    $sort = mysql_query("SELECT * FROM `logbook` ORDER BY (UNIX_TIMESTAMP(`datetime`)) ASC");    
                                    while ($row = mysql_fetch_array($sort)) {
                                    ?>
                                    <tr>
                                        <td><?php echo $row[2] ?></td>
                                        <td><?php echo $row[1] ?></td>
                                        <td><?php echo $row[4] ?></td>
                                        <td><a href="#"><?php echo $row[3] ?></a></td>
                                    </tr>
                                <?php } ?>    

     

    SQL Dump

     

    CREATE TABLE IF NOT EXISTS `logbook` (
      `id` int( NOT NULL AUTO_INCREMENT,
      `category` varchar(100) NOT NULL,
      `user` varchar(100) NOT NULL,
      `description` varchar(300) NOT NULL,
      `datetime` datetime NOT NULL,
      `userinfo` varchar(500) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
    
    --
    -- Dumping data for table `logbook`
    --
    
    INSERT INTO `logbook` (`id`, `category`, `user`, `description`, `datetime`, `userinfo`) VALUES
    (1, 'Backup File', '', 'File added with path = D:/Music/', '2012-06-05 09:09:51', 'a:6:{s:2:"ip";s:11:"127.0.0.1\r\n";s:4:"host";s:8:"Nuv-PC\r\n";s:7:"httpvia";s:6:"Direct";s:4:"date";s:22:"05/06/2012 10:09:51 AM";s:7:"browser";s:173:"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3)";s:10:"requesturi";s:29:"/file:/D:/HTML/storefile.php?";}'),
    (2, 'Backup File', '', 'File added with path = D:/Company/vroomweb/', '2012-06-05 11:19:47', 'a:6:{s:2:"ip";s:11:"127.0.0.1\r\n";s:4:"host";s:8:"Nuv-PC\r\n";s:7:"httpvia";s:6:"Direct";s:4:"date";s:22:"05/06/2012 12:19:47 PM";s:7:"browser";s:173:"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3)";s:10:"requesturi";s:29:"/file:/D:/HTML/storefile.php?";}'),
    (3, 'Backup File', '', 'File added with path = D:/Company/Form1.pdf', '2012-06-05 11:19:47', 'a:6:{s:2:"ip";s:11:"127.0.0.1\r\n";s:4:"host";s:8:"Nuv-PC\r\n";s:7:"httpvia";s:6:"Direct";s:4:"date";s:22:"05/06/2012 12:19:47 PM";s:7:"browser";s:173:"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3)";s:10:"requesturi";s:29:"/file:/D:/HTML/storefile.php?";}'),
    (7, 'User Login', 'Unknown User', 'Login attempt on admin', '2012-06-06 06:20:06', 'a:6:{s:2:"ip";s:11:"127.0.0.1\r\n";s:4:"host";s:8:"Nuv-PC\r\n";s:7:"httpvia";s:6:"Direct";s:4:"date";s:22:"06/06/2012 07:20:06 AM";s:7:"browser";s:173:"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3)";s:10:"requesturi";s:25:"/file:/D:/HTML/login.php?";}'),
    (8, 'User Login', 'Unknown User', 'Login attempt on admin', '2012-06-06 06:21:21', 'a:6:{s:2:"ip";s:11:"127.0.0.1\r\n";s:4:"host";s:8:"Nuv-PC\r\n";s:7:"httpvia";s:6:"Direct";s:4:"date";s:22:"06/06/2012 07:21:21 AM";s:7:"browser";s:173:"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3)";s:10:"requesturi";s:25:"/file:/D:/HTML/login.php?";}'),
    (9, 'User Login', 'admin', 'admin logged in.', '2012-06-06 06:21:53', 'a:6:{s:2:"ip";s:11:"127.0.0.1\r\n";s:4:"host";s:8:"Nuv-PC\r\n";s:7:"httpvia";s:6:"Direct";s:4:"date";s:22:"06/06/2012 07:21:53 AM";s:7:"browser";s:173:"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3)";s:10:"requesturi";s:25:"/file:/D:/HTML/login.php?";}');
    

  12. I'm trying to sort by my logbook with datetime. However, i am getting strange results when i use "ORDER BY datetime DESC". I searched over net and realized i need to use CONVERT. Though i am not able to understand it. Can someone please explain me

     

    My table structure -

     

    CREATE TABLE IF NOT EXISTS `logbook` (
      `id` int( NOT NULL AUTO_INCREMENT,
      `category` varchar(100) NOT NULL,
      `user` varchar(100) NOT NULL,
      `description` varchar(300) NOT NULL,
      `datetime` datetime NOT NULL,
      `userinfo` varchar(500) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
    

     

    Query I am using -

     

    "SELECT * FROM `logbook` ORDER BY CONVERT(datetime, date, 103) LIMIT 10"

     

    Though i am not getting any result. Can someone please point me in the right direction.

     

  13. Hi guys,

     

    I would like to make a web backup application where backed up data will be stored in the cloud server. I have few questions about security and compression.

     

    1. I need a good compression algo/technique. CPU usage is a bit critical. After some research, i see gzip is apt for my needs. Is that right ?

     

    2. I need some encryption algo too. After reading book on Applied Cryptography by Bruice Schneier and research, i found that AES is pretty good. Should i be using that ?

     

    3.Will i have/need to check for data integrity (by hashing algos like SHA-1 and MD5) too ? Or its used only for message integrity checking ?

     

    4. In what order should the process flow ? Compression then Encryption or vice- versa ?

     

    5. Am i missing anything, security related ? Use encryption algo, data integrity(if its necesarry) and send it to the cloud server where itll be stored that way.

     

     

    Thankyou.

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