Can't make PHP works with DB

Hey guys… I’ve been testing a new host: ueuo.com … trying to make a book management system with PHP using the following settings to connecto to DB:

function GetGlobalConnectionOptions() { return array( 'server' => 'localhost', 'port' => '3306', 'username' => '436392', 'password' => '******', 'database' => '436392' ...

(using the instructions of the host)

But all I get is a blank page when I try to acess a php file that use the content of my DB. Works fine in my notebook (localhost - XAMPP), can insert, delete, alter… The truth is that I can’t make it work in free web server found around… What may be happening?

  • already verified if my DB is right imported (YES)
  • already veriefied the specifications to connect to their DB (YES) (I am pretty sure the user and password are correct) (When I do it wrong it returns me: "Wrong user or password…)

Where’s the problem? In my hosts, port, code?

Thank you for your time! I will wait for answers so I can post the PHP file that get content from DB and my connection file.

it would help if you just post all the files the first time so we don’t have to revisit these questions, then we could give you a more informative answer the first time :wink:
we cannot tell you anything from what you have posted

Thank you for your reply!

This is the connect file
[php]<?php

// define(‘SHOW_VARIABLES’, 1);
// define(‘DEBUG_LEVEL’, 1);

// error_reporting(E_ALL ^ E_NOTICE);
// ini_set(‘display_errors’, ‘On’);

set_include_path(’.’ . PATH_SEPARATOR . get_include_path());

require_once ‘components/utils/system_utils.php’;

// SystemUtils::DisableMagicQuotesRuntime();

SystemUtils::SetTimeZoneIfNeed(‘America/Argentina/Buenos_Aires’);

function GetGlobalConnectionOptions()
{
return array(
‘server’ => ‘localhost’,
‘username’ => ‘436392’,
‘password’ => ‘*****’,
‘database’ => ‘436392’
);
}

function GetPageInfos()
{
$result = array();
$result[] = array(‘caption’ => ‘Livros’, ‘short_caption’ => ‘Livros’, ‘filename’ => ‘livros.php’, ‘name’ => ‘livros’);
$result[] = array(‘caption’ => ‘Outros’, ‘short_caption’ => ‘Outros’, ‘filename’ => ‘outros.php’, ‘name’ => ‘outros’);
$result[] = array(‘caption’ => ‘Wishlist’, ‘short_caption’ => ‘Wishlist’, ‘filename’ => ‘wishlist.php’, ‘name’ => ‘wishlist’);
return $result;
}

function GetPagesHeader()
{
return
‘’;
}

function GetPagesFooter()
{
return
‘’;
}

function ApplyCommonPageSettings($page, $grid)
{
$page->SetShowUserAuthBar(false);
$grid->BeforeUpdateRecord->AddListener(‘Global_BeforeUpdateHandler’);
$grid->BeforeDeleteRecord->AddListener(‘Global_BeforeDeleteHandler’);
$grid->BeforeInsertRecord->AddListener(‘Global_BeforeInsertHandler’);
}

/*
Default code page: 1252
*/
function GetAnsiEncoding() { return ‘windows-1252’; }

function Global_BeforeUpdateHandler($rowData, &$cancel, &$message)
{

}

function Global_BeforeDeleteHandler($rowData, &$cancel, &$message)
{

}

function Global_BeforeInsertHandler($rowData, &$cancel, &$message)
{

}

?>[/php]


This is one of the files that require content in DB

[php]<?php

require_once 'components/utils/check_utils.php';
CheckPHPVersion();

require_once 'database_engine/mysql_engine.php';
require_once 'components/page.php';
require_once 'phpgen_settings.php';

function GetConnectionOptions()
{
    $result = GetGlobalConnectionOptions();
    $result['client_encoding'] = 'utf8';
    GetApplication()->GetUserAuthorizationStrategy()->ApplyIdentityToConnectionOptions($result);
    return $result;
}

?><?php

?><?php

class outrosPage extends Page
{
    protected function DoBeforeCreate()
    {
        $this->dataset = new TableDataset(
            new MyConnectionFactory(),
            GetConnectionOptions(),
            '`outros`');
        $field = new IntegerField('Codigo', null, null, true);
        $this->dataset->AddField($field, true);
        $field = new StringField('Autor');
        $this->dataset->AddField($field, false);
        $field = new StringField('Titulo');
        $this->dataset->AddField($field, false);
        $field = new StringField('Editora');
        $this->dataset->AddField($field, false);
        $field = new StringField('Paginas');
        $this->dataset->AddField($field, false);
        $field = new StringField('Ano');
        $this->dataset->AddField($field, false);
        $field = new StringField('Obs');
        $this->dataset->AddField($field, false);
    }

    protected function CreatePageNavigator()
    {
        $result = new CompositePageNavigator($this);
        
        $partitionNavigator = new PageNavigator('pnav', $this, $this->dataset);
        $partitionNavigator->SetRowsPerPage(20);
        $result->AddPageNavigator($partitionNavigator);
        
        return $result;
    }

    public function GetPageList()
    {
        $currentPageCaption = $this->GetShortCaption();
        $result = new PageList();
        if (GetCurrentUserGrantForDataSource('livros')->HasViewGrant())
            $result->AddPage(new PageLink($this->RenderText('Livros'), 'livros.php', $this->RenderText('Livros'), $currentPageCaption == $this->RenderText('Livros')));
        if (GetCurrentUserGrantForDataSource('outros')->HasViewGrant())
            $result->AddPage(new PageLink($this->RenderText('Outros'), 'outros.php', $this->RenderText('Outros'), $currentPageCaption == $this->RenderText('Outros')));
        if (GetCurrentUserGrantForDataSource('wishlist')->HasViewGrant())
            $result->AddPage(new PageLink($this->RenderText('Wishlist'), 'wishlist.php', $this->RenderText('Wishlist'), $currentPageCaption == $this->RenderText('Wishlist')));
        return $result;
    }

    protected function CreateRssGenerator()
    {
        return null;
    }

    protected function CreateGridSearchControl($grid)
    {
        $grid->UseFilter = true;
        $grid->SearchControl = new SimpleSearch('outrosssearch', $this->dataset,
            array('Codigo', 'Autor', 'Titulo', 'Editora', 'Paginas', 'Ano', 'Obs'),
            array($this->RenderText('Codigo'), $this->RenderText('Autor'), $this->RenderText('Titulo'), $this->RenderText('Editora'), $this->RenderText('Paginas'), $this->RenderText('Ano'), $this->RenderText('Obs')),
            array(
                '=' => $this->GetLocalizerCaptions()->GetMessageString('equals'),
                '<>' => $this->GetLocalizerCaptions()->GetMessageString('doesNotEquals'),
                '<' => $this->GetLocalizerCaptions()->GetMessageString('isLessThan'),
                '<=' => $this->GetLocalizerCaptions()->GetMessageString('isLessThanOrEqualsTo'),
                '>' => $this->GetLocalizerCaptions()->GetMessageString('isGreaterThan'),
                '>=' => $this->GetLocalizerCaptions()->GetMessageString('isGreaterThanOrEqualsTo'),
                'ILIKE' => $this->GetLocalizerCaptions()->GetMessageString('Like'),
                'STARTS' => $this->GetLocalizerCaptions()->GetMessageString('StartsWith'),
                'ENDS' => $this->GetLocalizerCaptions()->GetMessageString('EndsWith'),
                'CONTAINS' => $this->GetLocalizerCaptions()->GetMessageString('Contains')
                ), $this->GetLocalizerCaptions(), $this, 'CONTAINS'
            );
    }

    protected function CreateGridAdvancedSearchControl($grid)
    {
        $this->AdvancedSearchControl = new AdvancedSearchControl('outrosasearch', $this->dataset, $this->GetLocalizerCaptions(), $this->GetColumnVariableContainer(), $this->CreateLinkBuilder());
        $this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateStringSearchInput('Codigo', $this->RenderText('Codigo')));
        $this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateStringSearchInput('Autor', $this->RenderText('Autor')));
        $this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateStringSearchInput('Titulo', $this->RenderText('Titulo')));
        $this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateStringSearchInput('Editora', $this->RenderText('Editora')));
        $this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateStringSearchInput('Paginas', $this->RenderText('Paginas')));
        $this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateStringSearchInput('Ano', $this->RenderText('Ano')));
        $this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateStringSearchInput('Obs', $this->RenderText('Obs')));
    }

    protected function AddOperationsColumns($grid)
    {
        $actionsBandName = 'actions';
        $grid->AddBandToBegin($actionsBandName, $this->GetLocalizerCaptions()->GetMessageString('Actions'), true);
        if ($this->GetSecurityInfo()->HasViewGrant())
        {
            $column = $grid->AddViewColumn(new RowOperationByLinkColumn($this->GetLocalizerCaptions()->GetMessageString('View'), OPERATION_VIEW, $this->dataset), $actionsBandName);
            $column->SetImagePath('images/view_action.png');
        }
        if ($this->GetSecurityInfo()->HasEditGrant())
        {
            $column = $grid->AddViewColumn(new RowOperationByLinkColumn($this->GetLocalizerCaptions()->GetMessageString('Edit'), OPERATION_EDIT, $this->dataset), $actionsBandName);
            $column->SetImagePath('images/edit_action.png');
            $column->OnShow->AddListener('ShowEditButtonHandler', $this);
        }
        if ($this->GetSecurityInfo()->HasDeleteGrant())
        {
            $column = $grid->AddViewColumn(new RowOperationByLinkColumn($this->GetLocalizerCaptions()->GetMessageString('Delete'), OPERATION_DELETE, $this->dataset), $actionsBandName);
            $column->SetImagePath('images/delete_action.png');
            $column->OnShow->AddListener('ShowDeleteButtonHandler', $this);
        $column->SetAdditionalAttribute("modal-delete", "true");
        $column->SetAdditionalAttribute("delete-handler-name", $this->GetModalGridDeleteHandler());
        }
        if ($this->GetSecurityInfo()->HasAddGrant())
        {
            $column = $grid->AddViewColumn(new RowOperationByLinkColumn($this->GetLocalizerCaptions()->GetMessageString('Copy'), OPERATION_COPY, $this->dataset), $actionsBandName);
            $column->SetImagePath('images/copy_action.png');
        }
    }

    protected function AddFieldColumns($grid)
    {

        $column = new TextViewColumn('Codigo', 'Codigo', $this->dataset);
        $column->SetOrderable(true);
        $column->SetDescription($this->RenderText(''));
        $column->SetFixedWidth(null);
        $grid->AddViewColumn($column);
        
        $column = new TextViewColumn('Autor', 'Autor', $this->dataset);
        $column->SetOrderable(true);
        
        /* <inline edit column> */

        $editor = new TextEdit('autor_edit');
        $editor->SetSize(50);
        $editColumn = new CustomEditColumn('Autor', 'Autor', $editor, $this->dataset);
        $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
        $editor->GetValidatorCollection()->AddValidator($validator);
        $this->ApplyCommonColumnEditProperties($editColumn);
        $column->SetEditOperationColumn($editColumn);
        /* </inline edit column> */
        
        /* <inline insert column> */

        $editor = new TextEdit('autor_edit');
        $editor->SetSize(50);
        $editColumn = new CustomEditColumn('Autor', 'Autor', $editor, $this->dataset);
        $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
        $editor->GetValidatorCollection()->AddValidator($validator);
        $this->ApplyCommonColumnEditProperties($editColumn);
        $column->SetInsertOperationColumn($editColumn);
        /* </inline insert column> */
        $column->SetDescription($this->RenderText(''));
        $column->SetFixedWidth(null);
        $grid->AddViewColumn($column);
        
        $column = new TextViewColumn('Titulo', 'Titulo', $this->dataset);
        $column->SetOrderable(true);
        $column->SetMaxLength(75);
        $column->SetFullTextWindowHandlerName('Titulo_handler');
        
        /* <inline edit column> */

        $editor = new TextAreaEdit('titulo_edit', 50, 8);
        $editColumn = new CustomEditColumn('Titulo', 'Titulo', $editor, $this->dataset);
        $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
        $editor->GetValidatorCollection()->AddValidator($validator);
        $this->ApplyCommonColumnEditProperties($editColumn);
        $column->SetEditOperationColumn($editColumn);
        /* </inline edit column> */
        
        /* <inline insert column> */
  
        $editor = new TextAreaEdit('titulo_edit', 50, 8);
        $editColumn = new CustomEditColumn('Titulo', 'Titulo', $editor, $this->dataset);
        $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
        $editor->GetValidatorCollection()->AddValidator($validator);
        $this->ApplyCommonColumnEditProperties($editColumn);
        $column->SetInsertOperationColumn($editColumn);
        /* </inline insert column> */
        $column->SetDescription($this->RenderText(''));
        $column->SetFixedWidth(null);
        $grid->AddViewColumn($column);

        $column = new TextViewColumn('Editora', 'Editora', $this->dataset);
        $column->SetOrderable(true);
        
        /* <inline edit column> */
 
        $editor = new TextEdit('editora_edit');
        $editor->SetSize(50);
        $editColumn = new CustomEditColumn('Editora', 'Editora', $editor, $this->dataset);
        $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
        $editor->GetValidatorCollection()->AddValidator($validator);
        $this->ApplyCommonColumnEditProperties($editColumn);
        $column->SetEditOperationColumn($editColumn);
        /* </inline edit column> */
        
        /* <inline insert column> */
    
        $editor = new TextEdit('editora_edit');
        $editor->SetSize(50);
        $editColumn = new CustomEditColumn('Editora', 'Editora', $editor, $this->dataset);
        $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
        $editor->GetValidatorCollection()->AddValidator($validator);
        $this->ApplyCommonColumnEditProperties($editColumn);
        $column->SetInsertOperationColumn($editColumn);
        /* </inline insert column> */
        $column->SetDescription($this->RenderText(''));
        $column->SetFixedWidth(null);
        $grid->AddViewColumn($column);

        $column = new TextViewColumn('Paginas', 'Paginas', $this->dataset);
        $column->SetOrderable(true);
        
        /* <inline edit column> */
       
        $editor = new TextEdit('paginas_edit');
        $editor->SetSize(4);
        $editColumn = new CustomEditColumn('Paginas', 'Paginas', $editor, $this->dataset);
        $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
        $editor->GetValidatorCollection()->AddValidator($validator);
        $this->ApplyCommonColumnEditProperties($editColumn);
        $column->SetEditOperationColumn($editColumn);
        /* </inline edit column> */
        
        /* <inline insert column> */
    
        $editor = new TextEdit('paginas_edit');
        $editor->SetSize(4);
        $editColumn = new CustomEditColumn('Paginas', 'Paginas', $editor, $this->dataset);
        $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
        $editor->GetValidatorCollection()->AddValidator($validator);
        $this->ApplyCommonColumnEditProperties($editColumn);
        $column->SetInsertOperationColumn($editColumn);
        /* </inline insert column> */
        $column->SetDescription($this->RenderText(''));
        $column->SetFixedWidth(null);
        $grid->AddViewColumn($column);
    
        $column = new TextViewColumn('Ano', 'Ano', $this->dataset);
        $column->SetOrderable(true);
        
        /* <inline edit column> */
    
        $editor = new TextEdit('ano_edit');
        $editor->SetSize(4);
        $editColumn = new CustomEditColumn('Ano', 'Ano', $editor, $this->dataset);
        $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
        $editor->GetValidatorCollection()->AddValidator($validator);
        $this->ApplyCommonColumnEditProperties($editColumn);
        $column->SetEditOperationColumn($editColumn);
        /* </inline edit column> */

I dont see these functions GetApplication()->GetUserAuthorizationStrategy() listed below so I have no idea what they are doing, could you make a more simple database connection page and include it to the files that are needed? Then comment out this database connection. That just might simplify things
[php]<?php
$dbhost = ‘localhost’;
$dbuser = ‘dbuser’;
$dbpass = ‘dbpass’;

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error());

$dbname = ‘dbname’;
mysql_select_db($dbname);
?>
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service