Jump to content

ali_kiyani

Members
  • Posts

    61
  • Joined

  • Last visited

    Never

Posts posted by ali_kiyani

  1. 1. With PDO you don't need to write separate code when you change database. mysql_connect will only work for MySQL and not MS SQL Server or Oracle. For that you will need to use different methods. PDO solve this problem.

     

    2. With PDO when you use parameters then all user input is automatically sanitized. You don't need to sanitize it.

  2. Couple questions:

    - Are you creating temporary tables in your queries (like, explicitly)?

    - Are you running SELECTs without LIMITs when you shouldn't be?

    - Are there actually 310 tables? Pardon the accusation but are you sure you need all of them?

     

    Basically, what kind of demand are you putting on it?

     

    1. No

    2. Yes there may be several queries. But the thing is I am not sure if just some of those queries will create such a problem. Could it be due to something else like I/O wait!?

    3. There are other applications also installed like cpanel, mail server e.t.c. who have their own databases so this is total of all tables not just my application.

  3. Hi,

     

    I have a dedicated server with following specs:

     

    1. Two Intel Xeon-Harpertown 5430-Quadcore[2.66 Ghz]

    2. 4GB DDRII RAM

    3. 500GB SATAII HD

    4. CentOS 5.5 64-bit

     

    Problem is that even with such specs MySQL still takes high CPU usage. It almost remain above 150% all the time and most of the time goes above 300%. I came to know about this after running "top" command.

    Now the thing is as soon as I run "watch mysqladmin pr" to see what's going on then I don't see any problem. Although there are queries running but they are not like some very heavy queries except may be one or two.

     

    I ran "mysqltunner.pl" and it showed me the following:

     

     

    -------- Storage Engine Statistics -------------------------------------------

    [--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster

    [--] Data in MyISAM tables: 362M (Tables: 255)

    [--] Data in InnoDB tables: 880K (Tables: 55)

    [!!] Total fragmented tables: 2

     

    -------- Performance Metrics -------------------------------------------------

    [--] Up for: 3h 26m 51s (1M q [138.122 qps], 43K conn, TX: 3B, RX: 246M)

    [--] Reads / Writes: 93% / 7%

    [--] Total buffers: 830.0M global + 3.9M per thread (300 max threads)

    [OK] Maximum possible memory usage: 1.9G (50% of installed RAM)

    [OK] Slow queries: 0% (47/1M)

    [OK] Highest usage of available connections: 6% (18/300)

    [OK] Key buffer size / total MyISAM indexes: 256.0M/169.9M

    [OK] Key buffer hit rate: 100.0% (5B cached / 36K reads)

    [OK] Query cache efficiency: 84.2% (1M cached / 1M selects)

    [!!] Query cache prunes per day: 338346

    [OK] Sorts requiring temporary tables: 0% (989 temp sorts / 242K sorts)

    [!!] Temporary tables created on disk: 38% (160K on disk / 420K total)

    [OK] Thread cache hit rate: 99% (18 created / 43K connections)

    [OK] Table cache hit rate: 98% (446 open / 452 opened)

    [OK] Open file limit used: 1% (663/65K)

    [OK] Table locks acquired immediately: 99% (684K immediate / 684K locks)

    [OK] InnoDB data size / buffer pool: 880.0K/8.0M

     

    -------- Recommendations -----------------------------------------------------

    General recommendations:

    Run OPTIMIZE TABLE to defragment tables for better performance

    MySQL started within last 24 hours - recommendations may be inaccurate

    Temporary table size is already large - reduce result set size

    Reduce your SELECT DISTINCT queries without LIMIT clauses

    Variables to adjust:

    query_cache_size (> 64M)

    ------------------------------------------------------------------------------

     

     

    As you can see most of the parameters are correct except a few like 2 defrag tables and small query cache size. Even if I fix this I don't see any noticeable performance increase. So now I have turned my attention to this "Temporary tables created on disk 38%"

    Do you think it is because of this MySQL is taking too much CPU time? How can I improve it? Or do you think there is something else after look at above result?

     

    Currently my setting regarding temporary tables in MySQL config file are:

     

    tmp_table_size=1000M

    max_heap_table_size=500M

     

    Even if I increase these values, MySQL still created temporary tables on disk. How do I fix it? I can see mysqltuner.pl also says that I need reduce my result set but if I give it plenty of RAM to create temp tables shouldn't the problem go away?

     

     

    Thanks

  4. You mean like this  http://www.wizecho.com/

     

    Not exactly because when of my requirement is that the HTML source code when viewed in browser should display that translated language for SEO purpose. What they are doing is converting text after it is displayed in browser. I want to translate before something is displayed on page and only translated content is displayed rather than first displaying English content and then translating to other language.

     

    But what ever their technique is, I want to know how to break HTML in 5000 characters properly.

  5. Hi,

     

    I am trying to translate a page in PHP using Google API. There is 5000 chars limit on data that you can send to Google at a time. So I am trying to break the page into pieces of 5000 chars. But as you know while doing this we have to keep in mind the HTML formatting that it should not be disturbed otherwise you will not get desired results.

     

    For example you have to send this:

     

    <a href="#" class="myclass">Link</a>

     

    Instead of this:

     

    <a href="#" class="myclas

     

    I am able to solve it somehow (although not perfectly I guess) by checking if "<" sign is coming after ">" sign or not. If "<" sign is coming after ">" then I go back to the point where I found ">" and cut string from there.

     

    Anyway the point is I am still having some problems regarding HTML formatting and want to know how to do it efficiently. Is there any parser available that will solve this problem!?

     

    Thanks

  6. Hi,

     

    I have the following file structure

     

    /.htaccess
    /index.php
    /displaypage.php

     

    All files are on root.

     

    I have following written in .htaccess file

     

    Options FollowSymLinks
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteRule ^([a-z0-9-]+)$ displaypage.php?page=$1 [NC,L]

     

    I have following written in displaypage.php

     

    echo $_GET["page"];

     

    Now when I run http://localhost/ then it shows index.php page which is correct. If I run http://localhost/something then it shows a blank page. Previously it used to display that "page" variable on screen. mod_rewrite is enabled and I am using Windows with XAMPP.

     

    What am I doing wrong?

     

    Thanks

  7. Hi,

     

    I am using Snoopy class to read contents of a web page. But it doesn't perfectly simulate the browser because the content of web page changes when I use Snoopy to fetch it. And if I view it in browser directly then content is different.

    I even set the user agent string in Snoopy but still no luck.

    How can we perfectly simulate browser so it is indistinguishable whether we are using some script or a browser to view web page?

     

    Thanks

  8. Hi,

     

    I have the following .htaccess file:

     

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-z0-9-]+) displaypage.php?page=$1 [NC,L]

     

    Using it I can read URLs like this:

     

    www.mywebsite.com/cats

    www.mywebsite.com/cars

    www.mywebsite.com/computers

     

    Now I want to modify .htaccess file so it can also read the following:

     

    www.mywebsite.com/cars/bmw

    www.mywebsite.com/computers/pc

     

    Think of 'cars' as category and 'bmw' as subcategory. I want to read both but because of my current .htaccess file I can only read categories and nothing after it.

     

    Thanks

  9. Hi,

     

    Can I create a SOAP server without WSDL? I mean this is the scenario:

     

    1. Client sends a parameter to server

    2. Server checks in database and returns result to the client

    3. Client displays result on screen

     

    So do I really need WSDL for that? Is there a way it should not require WSDL. Give me simple example code.

     

    Thanks

  10. Hi,

     

    I created the following server:

     

    function test($id)
    {
    if($id == "1")
    	return "OK";
    else
    	return "Bye";
    }
    
    ini_set("soap.wsdl_cache_enabled", "0");
    
    $server = new SoapServer("testserver.wsdl");
    
    $server->addFunction('test');
    
    $server->handle();
    

     

    And my client is:

     

    ini_set("soap.wsdl_cache_enabled", "0″);
    
    $client = new SoapClient("http://localhost/soap/testserver.wsdl");
    
    $id = $client->test("1");
    
    print $id;
    

     

    I am using XAMPP and phpinfo() shows that I have both SOAP client and server enabled. Anyway I tried to run the client in browser as follows:

     

    http://localhost/soap/soapclient.php
    

     

    But getting following error:

     

    Warning: SoapClient::SoapClient(http://localhost/soap/testserver.wsdl) [soapclient.soapclient]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in

     

     

    Do I need to register the server???? I thought I need to so I wrote this in browser:

     

    http://localhost/soap/soapserver.php

     

    But got error:

     

    WSDLSOAP-ERROR: Parsing WSDL: Couldn't load from 'testserver.wsdl' 

     

    I am on Windows XP Pro by the way. HELP!!

  11. Hi,

     

    Let's say I have a page MAIN.PHP in which one file is being included as INCLUDES/FILE.PHP

     

    I want to prevent direct access to FILE.PHP so that no body can do like this:

     

    http://www.somewebsite.com/includes/file.php

     

    All users should only be able to access like this:

     

    http://www.somewebsite.com/main.php (and this main.php includes the other file.php file)

     

    Is there some $_SERVER variable available to check if the file being accessed is currently running inside some other file or not!? Or is there another way of doing it.

     

    Thanks

  12. Thanks for the replies guys.

    Let me try simplexml. In the mean time tell me is there some kind of recursive parser available? Because the document I am parsing has no fixed tags and they may increase or decrease. So I will be needing recursive parser if available the will go through all available nodes/tags.

  13. Hi,

     

    I want to read an XML file which can be reached here.

     

    http://www.mazda.ca/eng/Vehicles/Mazda3/sedan_content/Mazda3_subnav02_content04.xml

     

    I looked for XML parsers on Google and found several results which were using PHP Expat to do the job. One of them is this one:

     

    http://www.linkstraffic.net/programming/php/xml/xmlparser.php

     

    But I found out that to parse any XML file you must know its structure and tags. That is each parsers will be tailor made to read that particular XML file. Now my questions are:

     

    1. Is there a generic parser available that will read all nodes and data?

     

    2. Looking at the XML file above which I want to read can you suggest one or two nodes which I can used in PHP? I am a little confused because all the examples are using simple XML files with tags like <author> and <title> e.t.c but my XML file has tags like following:

     

    <tr class="row_heading">

    <tr class="row_odd">

    <td align="left">

     

    So tell me shall I use tag <tr> or <tr class="row_heading">

  14. Hi,

     

    I have a website with two domains:

     

    website.com/myfolder

    website.net/myfolder

     

    I want to block access to website.com/myfolder while website.net/myfolder will remain accessible.

    Similarly website.com and website.net as a whole should be accessible. It's only website.com/myfolder that should be blocked.

    How do I write .htaccess file?

     

    Thanks

  15. Ok I tried to implement the CSS print technique as follows but it prints a blank page.

     

    <html>
        <head>
           <link rel=alternate media=print href="myfile1.doc">
           <title>PRINT CV</title>
        </head>
        <body>
            Print This Page
        </body>
    </html>
    

     

    The file myfile1.doc exsits and there is text written in it but it only prints a blank page. What could be the reason?

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