| re: can't see the error (PHP5)
On Sat, 18 Sep 2004 14:20:26 GMT, Martin Slingsby <Keizer.S@gmail.com> wrote:
[color=blue]
>Anyone who can decipher this error message? What is PHP trying to tell me?
>
>exception 'MysqlException'
>in /var/www/localhost/htdocs/phenixsp/include/DB.inc:72 Stack trace:
>#0 /var/www/localhost/htdocs/phenixsp/include/DB.inc(58):
>DB_MysqlStatement->__construct(NULL, 'SELECT * FROM u...')[/color]
Here's the big clue, the NULL.
[color=blue]
>#1 /var/www/localhost/htdocs/phenixsp/login.php(21):
>DB_Mysql->prepare('SELECT * FROM u...') #2 {main}
>
> $dbh = new DB_Mysql('$DBUSER', '$DBPASS', '$HOST', '$DB');[/color]
Single quotes? It's unlikely the database host is the literal string $HOST,
etc.
So this probably failed, but you didn't catch any exceptions or check for
errors. Regardless, you carry on:
[color=blue]
> $newquery = "SELECT * FROM users WHERE name = :1";
> try{
> $stmt = $dbh->prepare($newquery); //line 21[/color]
$dbh is at best in some sort of invalid, disconnected state so this will fail.
[color=blue]
>class DB_MysqlStatement {
> protected $result;
> protected $binds;
> public $query;
> public $dbh;
>
> public function __construct($dbh, $query){[/color]
The backtrace said the first parameter, $dbh, was NULL.
[color=blue]
> $this->query = $query;
> $this->dbh = $dbh;
> if(!is_resource($dbh)){[/color]
NULL is not a resource so:
[color=blue]
> throw new MysqlException("Not a valid database connection");[/color]
You get an exception thrown.
--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool |