Members: 16,996
Threads: 38,831
Posts: 159,349
Online: 30

Newest Member: Kl_broka@rediffmail.com


Odoo.tv - Outdoor Television


Sedo - Domains kaufen und verkaufen das Projekt mambers.com steht zum Verkauf Besucherstatistiken von mambers.com etracker® Web-Controlling statt Logfile-Analyse
Old 30.04.2007, 15:45   #1 (permalink)
Baby Mamber
 
Join Date: Jan 2005
Posts: 2
dafyd is on a distinguished road
Send a message via MSN to dafyd
Default Component database lookup problems

I've coded a fairly small PHP script that works fine on its own, and I now need to convert it into a Mambo component (for 4.5.1). So far, everything seems to work fine, except for database lookups...

If I run the following code in the script, the Mambo database lookup performs correctly and I get a result:

PHP Code:
$gymboQuery "SELECT name FROM mos_users WHERE id=$userID";
$database->setQuery($gymboQuery);
$user mysql_fetch_assoc($database->query());
echo 
"<p>Thanks <strong>".$user['name']."</strong>. Your User ID is <strong>".$userID."</strong>.</p>"
But if I put that code into a function and call that separately, nothing happens.

PHP Code:
echo "<p>Thanks <strong>".getUsername($userID)."</strong>. Your User ID is <strong>".$userID."</strong>.</p>"
where getUsername is
PHP Code:
function getUsername($uid){
    global 
$database;
    
$gymboQuery "SELECT name FROM mos_users WHERE id=$uid";
    
$database->setQuery($gymboQuery);
    
$user mysql_fetch_assoc($database->query());
    return 
$user['name'];

Practically identical code... but nothing is passed back to the first script. What am I missing?

There are about half a dozen such database lookups in various functions, none of which work. But when they're run directly from the script (not from the function) they work fine. The functions work fine when I'm not using the Mambo database global, so I assume something's going wrong there...
dafyd is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Backup and restore using cPanel and the Mambo Site backup component geoffs Mambo 4.5.1 'How Do I' Questions 3 22.09.2006 20:50
Database Query Component Problems. gc128 Mambo 4.5.1 General Talk 0 15.01.2006 00:29
1st component: problems... vavroom1 Component Development 4 21.09.2004 03:23
Problems with component accessing database earroyave Mambo 4.5 Installation and Upgrades 2 21.08.2004 15:25
phpBB Component - Install, Import, Admin Problems JackBreech Component 'How Do I' Questions 15 21.08.2004 00:57


All times are GMT +2. The time now is 21:18.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
A vBSkinworks Design
© Copyright 2004-2008 by Arthur Konze Webdesign.