1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Fixing PHP PEAR error

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 17, 2024 às 11:13.

  1. Stack

    Stack Membro Participativo

    I am trying to connect to MYSQL database and cannot. I believe it has something to do with the PEAR error, and I"ve looked at this answer but it has been of no use.

    Getting PEAR to work on XAMPP (Apache/MySQL stack on Windows)

    My code is the following:

    require 'DB.php';
    require 'formhelpers.php';

    $db = DB::connect('mysql://root:password@localhost/test');
    if (DB::isError($db)) { die("connection error: " . $db->getMessage( )); }
    $db->setErrorHandling(PEAR_ERROR_DIE);

    //create table for responses
    $q = $db->query(
    "CREATE TABLE apiResponse(
    Name VARCHAR(20),
    Occupation VARCHAR(20)");

    //select data to send
    $db = DB::connect('mysql://root:password@localhost/test');
    $q = $db->query('SELECT Name, Occupation FROM try2 ');
    while ($row = $q->fetchRow())
    {
    $Name = $row[0];
    $Occupation = $row[1];

    $q = $db->query(
    "INSERT INTO apiResponse (Name, Occupation) values ($Name, $Occupation)"
    );


    And I get the following errors:

    Warning: require(formhelpers.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\myfiles\Testing API Script.php on line 10

    Fatal error: require() [function.require]: Failed opening required 'formhelpers.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\myfiles\Testing API Script.php on line 10

    Now, according to the other answer, this is a problem with finding PEAR. I have located the php.ini file and found the include statement. It is PHP's default setting for include_path is ".;/path/to/php/pear" which is what the answer suggested.

    My questions:


    1. The file that needs to be corrected is the php.ini file in xamp? (I previously downloaded php straight from php.net)


    2. I have both a php.ini for development and for production... which one do I edit?


    3. The .ini file opens in notepad, I'm not sure this is the correct place to edit it. Confirmation?

    Continue reading...

Compartilhe esta Página