Re: PDO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2012-10-22 at 23:27 +0200, Silvio Siefke wrote:

> Hello,
> 
> i have built php 5.4.7 on Ubuntu with the configure Arguments like on my 
> Gentoo System. But on Gentoo run the website without Problems, under Ubuntu
> want not work. I become in error.log:
> 
> [22-Oct-2012 21:15:00 UTC] PHP Fatal error:  Call to a member function 
> prepare() on a non-object in html/index.html on line 23
> 
> U use PHP FPM with Nginx. 
> 
> The configure Arguments:
> http://pastebin.geany.org/qz8TP/
> 
> The Script which work:
> <?php
> require_once ("db.php");
> 
> $query = $db->prepare("SELECT id, title, date FROM bloggen ORDER BY date DESC LIMIT 0,5");
> if (!$query) {die("Execute query error, because: " . $db->errorInfo());}
> 
> $query->execute();
> 
> while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
> echo "<p><a href=\"/blog/post.html?id=".$row['id']."\" title=\"".(htmlentities($row['title'], ENT_QUOTES, "UTF-8"))."\">".(htmlentities($row['title'], ENT_QUOTES, "UTF-8"))."</a></p>\n";
> }
> 
> $row = null;
> $query = null;
> $db = null;
> ?>
> 
> 
> Has someone a idea what is there wrong?
> 
> 
> Thanks for help and nice Day.
> 
> Silvio
> 


It's a bit odd that you're parsing all .html files as if they were PHP
(little bit of a waste, and does mean you'll have an extra step when
configuring a server to run the code)

That aside, I don't see 23 lines of code in your example, so I'm
assuming you've snipped a lot of the beginning (you've not mentioned in
particular which line in your excerpt is the 23rd). What's in your
db.php include? Are there any checks on whether a connection has been
established or not there?
-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux