View Full Version : Fatal error: Call to a member function on a non-object

16 Jun 2005, 20:57
I have a query that used to work before I installed 3.5 Now I get this error message whenever I load the page
Fatal error: Call to a member function on a non-object in /./././htdocs/widget.php on line 5

This is the contents of widget.php

require 'global.php';

$latestThreads = $DB_site->query("
FROM " . TABLE_PREFIX . "thread AS thread
WHERE thread.visible = 1
ORDER BY dateline DESC
$num_rows = $DB_site->num_rows($latestThreads);
while($row = $DB_site->fetch_array($latestThreads) )
echo('<a href="http://www.xblteams.com/forums/showthread.php?t=' . $row[threadid] . '">' . $row[title] . '</a><br />');


That worked before 3.5. What changed? and what do I need to change to make it work?

Also I would like to get it so the links are formatted like this

<a href="javascript:widget.openURL('http://www.xblteams.com/forums/showthread.php?t=put thread id here')"></a>

I've tried

echo('<a href="javascript:widget.openURL('http://www.xblteams.com/forums/showthread.php?t=' . $row[threadid] . ' ')">' . $row[title] . '</a><br />');

but I get a parse error.
Thanks in advance.

16 Jun 2005, 21:05
That worked before 3.5. What changed? and what do I need to change to make it work?

$DB_site is now $db.

And you should use query_read/query_write instead of just query depending if you are reading from or writing to the database.

echo('<a href="javascript:widget.openURL(\'http://www.xblteams.com/forums/showthread.php?t=' . $row[threadid] . '\')">' . htmlentities($row[title]) . '</a><br />');

should work.

The htmlspecialchars_uni() is necesarry, otherwise you create an XSS vulnerbilitie.

16 Jun 2005, 21:51
Hmmm that fixed the error and appears to be formatting the link correctly. What I am trying to do is create a widget for mac os 10.4 so far the only way I have found to get a widget to open up a link in safari is javascript:widget.openURL

From what I can tell the php file is doing it's job perfectly.
Here's an example of a link that it's pumping out.

<a href="javascript:widget.openURL('http://www.xblteams.com/forums/showthread.php?t=4257')">Call of Duty screenshots</a>

That should work because I have tested.
<a href="javascript:widget.openURL('http://www.xblteams.com/')">Xblteams.com</a>

Directly inside the widge and it works. I am guessing there must be an issue with the way I am loading the links into the widget.

here's the body of the widget

<body background="Default.png">
<table cellpadding="20">
<IFRAME SRC="http://www.xblteams.com/widget.php" WIDTH=180 HEIGHT=240>

From the testing I have done the iframe is causing the problem. The reason I think this is I created a file with just <a href="javascript:widget.openURL('http://www.xblteams.com/')">Xblteams.com</a>

and loaded it via an Iframe and it didn't work either. By not working I mean when I click the link nothing happens.

Is there a better way to load the links in?
widgets support javascript, and html.