Can't call Email field using php code

Cres_PTO 24 Mar, 2010
Hello,

I recently upgraded from Joomla 1.0 to 1.5. The php coding that I was using in my forms on the old site do not work on the new site.

1. I use the Profile plugin to call the field data once the member logs on, but as 'email' field is not in jos_comprofiler I used the following php coding to call the user's address:
<input type="text" id="email" name="email" size="40" value="<?php global $my; echo $my->email; ?>" />

The result is nothing. I get only an empty cell.

2. I would call table data from a database table in another form using the following php code,

<?php
global $database;

$query_classes = "SELECT * FROM `memdir2` ORDER BY `index`";
$database->setQuery($query_classes);
$results= $database->query();
if (!$results) {
echo "Could not successfully run query ($query_classes) from DB: " . mysql_error();
exit;
}


?>

The result is a Fatal Error regarding the setQuery().

I've search all over this forum looking for answers prior to submitting this post, and I've found nothing. I would appreciate any direction you could give me.

Thanks,
Marty
GreyHead 24 Mar, 2010
Hi Cres_PTO,

I think that there is a guide to the code Joomla changed from 1.0 to 1.5 in the Joomla Docs site somewhere.

$my is now replaced by the Joomla User object $user =& JFactory::getUser();

And $database is now the Joomla Database Object $db =& JFactory::getDBO();

You can no longer rely on the global declarations for either object.

Bob
Cres_PTO 24 Mar, 2010
Thanks for responding. I'll check it out.
Thanks,
Marty
Cres_PTO 24 Mar, 2010
Works Great!
Thanks,
Marty
This topic is locked and no more replies can be posted.