Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/05/2014, 08:20
AprendizPollito
 
Fecha de Ingreso: abril-2014
Mensajes: 26
Antigüedad: 10 años
Puntos: 0
Fatal error: Call to a member function getAll()

Buenas, tengo un problemilla haber si me ayudan

Este es el problema :


Código PHP:
Fatal errorCall to a member function getAll() on a non-object in C:xampphtdocsejemplo.comindex.php on line 47 

Esto es lo que intento hacer :

Poner un sistema de votos por estrellas (lo clásico xd)

dejare dos archivos: 1primero el del index.php y el 2segundo de la conexion...

1. primero : index.php

Código PHP:
<?php

if (version_compare(phpversion(), "5.3.0"">=")  == 1)
  
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
else
  
error_reporting(E_ALL & ~E_NOTICE); 
require_once(
'connections/conexionejemplo.php');


$sCode '';
$iItemId = (int)$_GET['id'];
if (
$iItemId) { // View item output
    
$aItemInfo $GLOBALS['MySQL']->getRow("SELECT * FROM `ejemplo` WHERE `id` = '{$iItemId}'"); // getting info about item from database
    
$sCode .= '<h1>'.$aItemInfo['title'].'</h1>';
    
$sCode .= '<h3>'.date('F j, Y'$aItemInfo['when']).'</h3>';
    
$sCode .= '<h2>Description:</h2>';
    
$sCode .= '<h3>'.$aItemInfo['description'].'</h3>';

    
// draw voting element
    
$iIconSize 64;
    
$iMax 5;
    
$iRate $aItemInfo['rate'];
    
$iRateCnt $aItemInfo['rate_count'];
    
$fRateAvg = ($iRate && $iRateCnt) ? $iRate $iRateCnt 0;
    
$iWidth $iIconSize*$iMax;
    
$iActiveWidth round($fRateAvg*($iMax $iWidth/$iMax 0));

    
$sVot '';
    for (
$i=$i<=$iMax $i++) {
        
$sVot .= '<a href="#" id="'.$i.'"><img class="votes_button" src="images/empty.gif" alt="" /></a>';
    }

    
$sVoting = <<<EOS
<div class="votes_main">
    <div class="votes_gray" style="width:
{$iWidth}px;">
        <div class="votes_buttons" id="
{$iItemId}" cnt="{$iRateCnt}" val="{$fRateAvg}">
            
{$sVot}
        </div>
        <div class="votes_active" style="width:
{$iActiveWidth}px;"></div>
    </div>
    <span><b>
{$iRateCnt}</b> votes</span>
</div>
EOS;

    
$sCode .= $sVoting;
    
$sCode .= '<h3><a href="'.$_SERVER['PHP_SELF'].'">back</a></h3>';
} else {
    
$sCode .= '<h1>List of items:</h1>';

    
$aItems $GLOBALS['MySQL']->getAll("SELECT * FROM `ejemplo` ORDER by `when` ASC"); // taking info about all items from database
    
foreach ($aItems as $i => $aItemInfo) {
        
$sCode .= '<h2><a href="'.$_SERVER['PHP_SELF'].'?id='.$aItemInfo['id'].'">'.$aItemInfo['title'].' item</a></h2>';
    }
}

?>
<!DOCTYPE html>
<html lang="en" >
    <head>
        <meta charset="utf-8" />
        <title>Creating own rate system</title>

        <link href="css/main.css" rel="stylesheet" type="text/css" />
        <script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
        <script type="text/javascript" src="js/script.js"></script>
    </head>
    <body>
        <div class="container">
            <?= $sCode ?>
        </div>
        
    </body>
</html>
2. segundo : conexionejemplo.php

Código PHP:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conexionejemplo "localhost";
$database_conexionejemplo "ejemplo";
$username_conexionejemplo "root";
$password_conexionejemplo "";
$conexionwimne mysql_pconnect($hostname_conexionejemplo$username_conexionejemplo$password_conexionejemplo) or trigger_error(mysql_error(),E_USER_ERROR); 
?>
Cita:
Estuve viendo en google el error y sale que es porque la conexion a la base de datos no esta definida, pues este codigo yo lo descarge de google y nose como hacerlo para que quede con el ejemplo...ayuda please!

Y si borro lo de las primeras lineas :

Código PHP:
<?php

if (version_compare(phpversion(), "5.3.0"">=")  == 1)
  
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
else
  
error_reporting(E_ALL & ~E_NOTICE); ?>
sale mas errores :

Código:
Notice: Undefined index: id in C:\xampp\htdocs\ejemplo.com\index.php on line 8

Notice: Undefined index: MySQL in C:\xampp\htdocs\ejemplo.com\index.php on line 47