Jump to content
php.lv forumi

dxshindeo

Reģistrētie lietotāji
  • Posts

    9
  • Joined

  • Last visited

Posts posted by dxshindeo

  1. Sveiki,

    ejošs kods:

     

    index.php

    
    //---------connect part-----------------
    try
    {
    $hostname = "localhost";
    $dbname = "resursi";
    $username = "root";
    $pw = "root";
    $pdo = new PDO ("mysql:host=$hostname;dbname=$dbname","$username","$pw");
    }
    
    catch (PDOException $e)
    {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
    }
    
    //-----------Fetching part-----------
    $from = 0;
    $limit = 10;
    $query = $pdo->prepare("SELECT * FROM archive ORDER BY id desc LIMIT $from, $limit");
    $query->execute();
    
    for($i=0; $row = $query->fetch(); $i++)
    {
    echo $i." - ".$row['author']."<br/>";
    }
    

     

     

     

     

    Es vēlos šo kodu sadalīt index.php un connect.php.

     

    connect.php

    
    //---------connect part-----------------
    try
    {
    $hostname = "localhost";
    $dbname = "resursi";
    $username = "root";
    $pw = "root";
    $pdo = new PDO ("mysql:host=$hostname;dbname=$dbname","$username","$pw");
    }  
    
    catch (PDOException $e)
    {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
    }
    
    

     

     

    index.php

    
    include "connect.php";
    
    //-----------Fetching part-----------
    
    $from = 0;
    $limit = 10;
    
    $query = $pdo->prepare("SELECT * FROM archive ORDER BY id desc LIMIT $from, $limit");
    $query->execute();
    
    for($i=0; $row = $query->fetch(); $i++)
    {
    echo $i." - ".$row['author']."<br/>";
    }
    
    

     

    Throws "Fatal error: Call to a member function prepare() on a non-object ".

     

    Vai ir kāds veids kā to paveikt?

  2. Sveiki,

    izmantoju sekojošas funkcijas:

     

    $datums = date("Y.m.d", time());

    $laiks = date('H:i', time());

     

    Uz localhosta viss čiki strādā.

    Tagad saits ir uzhostēts kaut kur ārzemēs un tagad laiks rādās -7h.

     

    How to deal with this problem?

  3. "1.9 Gb" - 1.9 MB :)

     

    Ok, here's part of my code (big query and an if-else statement):

     

    $result = mysql_query("INSERT INTO arhivs (prieksmets, prieksmets_full_name, nosaukums, tips, formats, izmers, autors, datums, laiks, path, saturs) VALUES ('$prieksmets', '$prieksmets_full_name', '$fileName', '$fileType', '$fileExt', '$fileSize', '$autors', '$datums', '$laiks', '$newpath', '$content')");
    
    if($result==true)
    {
    move_uploaded_file($_FILES["userfile"]["tmp_name"],$newpath);
    echo "Fails veiksmīgi pievienots. Paldies!";
    }
    else
    {
    echo mysql_error();
    }
    

     

    If file is < than 1.90 MB, everything echoes fine, but when it's >- 1.90 MB then it's supposed to show why query can't be executed, but it doesn't.

  4. Using Apache2.2, in httpd configuration file added:

     

    LoadModule php5_module "c:/php/php5apache2_2.dll

    AddType application/x-httpd-php .php"

     

    So the Apache can interact with PHP.

    Restarted Apache, nothing changes.

     

    What did you meant by mysqld?

     

    Checked my processes, have httpd and mysqld both up and running.

  5. Hi, everyone!

     

    I can't upload files bigger than 1,90 MB. 1,89 still works fine, but server refuses if higher.

     

    php.ini ->

    post_max_size = 100M

    upload_max_filesize = 100M

     

    Actually, the problem was that I was able to upload only 1 MB, problem was in mysql, fixed it by running sql commands:

     

    SET GLOBAL max_allowed_packet = 104857600; /*Theoretically this should let me upload and insert files with maximum size of 100 MB, but practically it raised the bar from 1 MB to 1,90 MB*/

     

    SET GLOBAL net_read_timeout = 3600; /*This was 30, dunno why I even touched this*/

     

    Field in mysql has LONGBLOB type, so it can contain a file ~4GB.

     

    Working with Win7 and I have installed and configured Apache2.2, MySQL Workbench 5.2.40 and PHP 5.2.17 (VC6 x86 Thread Safe version).

     

    Would appreciate any thoughts on the matter smile.gif

×
×
  • Create New...