[imp] Fw: 10. Gettting From address from sql db (Gennaro) imp Digest,
Vol 261, Issue 1
Gennaro
gennaro at snet.net
Thu Jan 2 08:49:44 PST 2003
For anyone interested I got it working
first I tried diffrent options with the
$sql = "select address from users where id = '$imp['user']'";
statement
$sql = "select address from users where id = _$imp[user]'";
$sql = "select address from users where id = {_$imp['user']}";
niether worked
So i set another variable to $imp['user'] and used it in the sql statement
the $imp['user'] did not like being inside double quotes
if (!function_exists('imp_expand_fromaddress')) {
function imp_expand_fromaddress($imp) {
$db = mysql_connect("localhost", "root", "h4g4nei");
mysql_select_db("maildb",$db);
$fromaddr = $imp['user'];
$sql = "select address from users where id = \"$fromaddr\"";
$result = mysql_query($sql,$db);
$name = mysql_result($result,0,"address");
return (empty($name) ? $imp['user'] : $name);
}
}
> ----- Original Message -----
> From: "Gennaro" <gennaro at snet.net>
> To: <imp at lists.horde.org>
> Sent: Thursday, January 02, 2003 7:36 AM
> Subject: Re: 10. Gettting From address from sql db (Gennaro) imp Digest,
Vol
> 261, Issue 1
>
>
> > Hello List
> >
> > I have narrowed my problem down to the $sql line
> > I have tried the line multiple ways but still problems exsist.
> > $sql = "select address from users where id = \"$imp['user']\"";
> > $sql = "select address from users where id = \'$imp['user']\'";
> > $sql = "select address from users where id = $imp['user']";
> > $sql = "select address from users where id = "$imp['user']"";
> > $sql = "select address from users where id = '$imp['user']'";
> >
> >
> > If i replace the $imp['user'] with an actuall username and then loging
as
> > that user it does what it is supposed to do it pulls thier email address
> out
> > of the database. For some reason whenever I try to use $imp['user'] I
run
> > into trouble. I have placed a print $imp['user'] line in my
> > /horde/templates/login/user.inc and when I login it does pass the
correct
> > info. However, when I try to use the variable in my from function It
> > generates errors. I was under the assumption that it should not even
try
> to
> > call this function until I login so I am not sure why I generate errors
> > before I ever login.
> >
> > any help would be appreciated
> >
> >
> > > 10. Gettting From address from sql db (Gennaro)
> > >
> > > Date: Tue, 31 Dec 2002 09:12:03 -0500
> > > From: "Gennaro" <gennaro at snet.net>
> > > To: <imp at lists.horde.org>
> > > Subject: [imp] Gettting From address from sql db
> > > Message-ID: <001401c2b0d6$979f13b0$9d4157d1 at dsl.net>
> > > Content-Type: text/plain;
> > > charset="iso-8859-1"
> > > MIME-Version: 1.0
> > > Content-Transfer-Encoding: quoted-printable
> > > Precedence: list
> > > Message: 10
> > >
> > > Any help on this would be appreciated
> > >
> > > I am trying to pull the from address from an sql db I have written
the
> =
> > > following in /imp/config/conf.php
> > >
> > > $conf['hooks']['from'] =3D 'imp_expand_fromaddress';
> > >
> > > if (!function_exists('imp_expand_fromaddress')) {
> > > function imp_expand_fromaddress($imp) {
> > > $db =3D mysql_connect("localhost", "username", "password");
> > > mysql_select_db("maildb",$db);
> > > $sql =3D "select address from users where id =3D '$imp['user']'";
> > > $result =3D mysql_query($sql,$db);
> > > $name =3D mysql_result($result,0,"address");
> > > return (empty($name) ? $imp['user'] : $name);
> > > }
> > > }
> > > But when I try to connect to the server I get
> > >
> > > Notice: Undefined index: alternate_login in =
> > > /home/www/default/horde/imp/login.php on line 90
> > >
> > > Notice: Undefined index: server in
/home/www/default/horde/imp/login.php
> =
> > > on line 136
> > >
> > > =20
> > > =20
> > > =20
> > >
> > > Notice: Undefined index: server in =
> > > /home/www/default/horde/imp/templates/login/login.inc on line 80
> > >
> > > Notice: Undefined index: server in =
> > > /home/www/default/horde/imp/templates/login/login.inc on line 83
> > >
> > > Notice: Undefined index: server in =
> > > /home/www/default/horde/imp/templates/login/login.inc on line 89
> > > =20
> > > Notice: Undefined index: server in =
> > > /home/www/default/horde/imp/templates/login/login.inc on line 127
> > > =20
> > >
> > > ------------------------------
> > >
> >
> >
>
More information about the imp
mailing list