Errores en mi codigo
Hola!
Estoy intentando enviar un boletin a mis usuarios registrados, el codigo para el envio te lo pongo al final, pero cuando lo intento enviar me salen errores referidos a la parte del codigo siguiente:
// include PEAR mail classes
include('Mail.php');
include('Mail/mime.php');
los errores que me dan son:
Warning: send(Mail/mime.php): failed to open stream: No such file or directory
Warning: send(): Failed opening 'Mail/mime.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php')
Cannot instantiate non-existent class: mail_mime
Codigo :
<?php
// do we already have a record of this subscriber?
function subscriber_exists($email)
{
if(!$email)
return false;
if(!db_connect())
return false;
$query = "select count(*) from subscribers where email = '$email'";
$result = mysql_query($query);
if(!$result)
return false;
return (mysql_result($result, 0, 0)>0);
}
// is this email address subscribed to this list?
function subscribed($email, $listid)
{
if(!$email||!$listid)
return false;
if(!db_connect())
return false;
$query = "select count(*) from sub_lists where email = '$email'
and listid = $listid";
$result = mysql_query($query);
if(!$result)
return false;
return (mysql_result($result, 0, 0)>0);
}
// is this listid the id of a list?
function list_exists($listid)
{
if(!$listid)
return false;
if(!db_connect())
return false;
$query = "select count(*) from lists where listid = '$listid'";
$result = mysql_query($query);
if(!$result)
return false;
return (mysql_result($result, 0, 0)>0);
}
// get the name of the person with this email
function get_real_name($email)
{
if(!$email)
return false;
if(!db_connect())
return false;
$query = "select realname from subscribers where email = '$email'";
$result = mysql_query($query);
if(!$result)
return false;
return trim(mysql_result($result, 0, 0));
}
// get the type (HTML or Text) that this person wants email in
function get_mimetype($email)
{
if(!$email)
return false;
if(!db_connect())
return false;
$query = "select mimetype from subscribers where email = '$email'";
$result = mysql_query($query);
if(!$result)
return false;
return trim(mysql_result($result, 0, 0));
}
// subscribe this email address to this list
function subscribe($email, $listid)
{
if(!$email||!$listid||!list_exists($listid)||!subscriber_exists($email))
return false;
//if already subscribed exit
if(subscribed($email, $listid))
return false;
if(!db_connect())
return false;
$query = "insert into sub_lists values ('$email', $listid)";
$result = mysql_query($query);
return $result;
}
// unsubscribe this email address from this list
function unsubscribe($email, $listid)
{
if(!$email||!$listid)
return false;
if(!db_connect())
return false;
$query = "delete from sub_lists where email = '$email' and listid = $listid";
$result = mysql_query($query);
return $result;
}
// load the data stored about this mail from the database
function load_mail_info($mailid)
{
if(!$mailid)
return false;
if(!db_connect())
return false;
$query = "select subject, listid, status, sent from mail
where mailid = $mailid";
$result = mysql_query($query);
if(!$result)
{
echo "Cannot retrieve this mail $query";
return false;
}
return mysql_fetch_array($result);
}
// load the data stored about this list from the database
function load_list_info($listid)
{
if(!$listid)
return false;
if(!db_connect())
return false;
$query = "select listname, blurb from lists where listid = $listid";
$result = mysql_query($query);
if(!$result)
{
echo 'Cannot retrieve this list';
return false;
}
$info = mysql_fetch_array($result);
$query = "select count(*) from sub_lists where listid = $listid";
$result = mysql_query($query);
if($result)
{
$info['subscribers'] = mysql_result($result, 0, 0);
}
$query = "select count(*) from mail where listid = $listid
and status = 'SENT'";
$result = mysql_query($query);
if($result)
{
$info['archive'] = mysql_result($result, 0, 0);
}
return $info;
}
// get the name that belongs to this list id
function get_list_name($listid)
{
if(!$listid)
return false;
if(!db_connect())
return false;
$query = "select listname from lists where listid = $listid";
$result = mysql_query($query);
if(!$result)
{
return false;
}
return mysql_result($result, 0);
}
// add a new list to the database
function store_list($admin_user, $details)
{
if(!filled_out($details))
{
echo 'All fields must be filled in. Try again.<br /><br />';
return false;
}
else
{
if(!check_admin_user($admin_user))
return false;
// how did this function get called by somebody not logged in as admin?
if(!db_connect())
{
return false;
}
$query = "select count(*) from lists where listname = '".$details['name']."'";
$result = mysql_query($query);
if(mysql_result($result, 0, 0) > 0)
{
echo 'Sorry, there is already a list with this name.';
return false;
}
$query = "insert into lists values (NULL,
'".$details['name']."',
'".$details['blurb']."')";
$result = mysql_query($query);
return $result;
}
}
// get the lists that this user is subscribed to
function get_subscribed_lists($email)
{
$list = array();
$query = "select lists.listid, listname from sub_lists, lists
where email='$email' and lists.listid = sub_lists.listid
order by listname";
if(db_connect())
{
$result = mysql_query($query);
if(!$result)
echo '<p>Unable to get list from database.';
$num = mysql_numrows($result);
for($i = 0; $i<$num; $i++)
{
array_push($list, array(mysql_result($result, $i, 0),
mysql_result($result, $i, 1)));
}
}
return $list;
}
//get the lists that this user is *not* subscribed to
function get_unsubscribed_lists($email)
{
$list = array();
$query = "select lists.listid, listname, email from lists left join sub_lists
on lists.listid = sub_lists.listid
and email='$email' where email is NULL order by listname";
if(db_connect())
{
$result = mysql_query($query);
if(!$result)
echo...
Estoy intentando enviar un boletin a mis usuarios registrados, el codigo para el envio te lo pongo al final, pero cuando lo intento enviar me salen errores referidos a la parte del codigo siguiente:
// include PEAR mail classes
include('Mail.php');
include('Mail/mime.php');
los errores que me dan son:
Warning: send(Mail/mime.php): failed to open stream: No such file or directory
Warning: send(): Failed opening 'Mail/mime.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php')
Cannot instantiate non-existent class: mail_mime
Codigo :
<?php
// do we already have a record of this subscriber?
function subscriber_exists($email)
{
if(!$email)
return false;
if(!db_connect())
return false;
$query = "select count(*) from subscribers where email = '$email'";
$result = mysql_query($query);
if(!$result)
return false;
return (mysql_result($result, 0, 0)>0);
}
// is this email address subscribed to this list?
function subscribed($email, $listid)
{
if(!$email||!$listid)
return false;
if(!db_connect())
return false;
$query = "select count(*) from sub_lists where email = '$email'
and listid = $listid";
$result = mysql_query($query);
if(!$result)
return false;
return (mysql_result($result, 0, 0)>0);
}
// is this listid the id of a list?
function list_exists($listid)
{
if(!$listid)
return false;
if(!db_connect())
return false;
$query = "select count(*) from lists where listid = '$listid'";
$result = mysql_query($query);
if(!$result)
return false;
return (mysql_result($result, 0, 0)>0);
}
// get the name of the person with this email
function get_real_name($email)
{
if(!$email)
return false;
if(!db_connect())
return false;
$query = "select realname from subscribers where email = '$email'";
$result = mysql_query($query);
if(!$result)
return false;
return trim(mysql_result($result, 0, 0));
}
// get the type (HTML or Text) that this person wants email in
function get_mimetype($email)
{
if(!$email)
return false;
if(!db_connect())
return false;
$query = "select mimetype from subscribers where email = '$email'";
$result = mysql_query($query);
if(!$result)
return false;
return trim(mysql_result($result, 0, 0));
}
// subscribe this email address to this list
function subscribe($email, $listid)
{
if(!$email||!$listid||!list_exists($listid)||!subscriber_exists($email))
return false;
//if already subscribed exit
if(subscribed($email, $listid))
return false;
if(!db_connect())
return false;
$query = "insert into sub_lists values ('$email', $listid)";
$result = mysql_query($query);
return $result;
}
// unsubscribe this email address from this list
function unsubscribe($email, $listid)
{
if(!$email||!$listid)
return false;
if(!db_connect())
return false;
$query = "delete from sub_lists where email = '$email' and listid = $listid";
$result = mysql_query($query);
return $result;
}
// load the data stored about this mail from the database
function load_mail_info($mailid)
{
if(!$mailid)
return false;
if(!db_connect())
return false;
$query = "select subject, listid, status, sent from mail
where mailid = $mailid";
$result = mysql_query($query);
if(!$result)
{
echo "Cannot retrieve this mail $query";
return false;
}
return mysql_fetch_array($result);
}
// load the data stored about this list from the database
function load_list_info($listid)
{
if(!$listid)
return false;
if(!db_connect())
return false;
$query = "select listname, blurb from lists where listid = $listid";
$result = mysql_query($query);
if(!$result)
{
echo 'Cannot retrieve this list';
return false;
}
$info = mysql_fetch_array($result);
$query = "select count(*) from sub_lists where listid = $listid";
$result = mysql_query($query);
if($result)
{
$info['subscribers'] = mysql_result($result, 0, 0);
}
$query = "select count(*) from mail where listid = $listid
and status = 'SENT'";
$result = mysql_query($query);
if($result)
{
$info['archive'] = mysql_result($result, 0, 0);
}
return $info;
}
// get the name that belongs to this list id
function get_list_name($listid)
{
if(!$listid)
return false;
if(!db_connect())
return false;
$query = "select listname from lists where listid = $listid";
$result = mysql_query($query);
if(!$result)
{
return false;
}
return mysql_result($result, 0);
}
// add a new list to the database
function store_list($admin_user, $details)
{
if(!filled_out($details))
{
echo 'All fields must be filled in. Try again.<br /><br />';
return false;
}
else
{
if(!check_admin_user($admin_user))
return false;
// how did this function get called by somebody not logged in as admin?
if(!db_connect())
{
return false;
}
$query = "select count(*) from lists where listname = '".$details['name']."'";
$result = mysql_query($query);
if(mysql_result($result, 0, 0) > 0)
{
echo 'Sorry, there is already a list with this name.';
return false;
}
$query = "insert into lists values (NULL,
'".$details['name']."',
'".$details['blurb']."')";
$result = mysql_query($query);
return $result;
}
}
// get the lists that this user is subscribed to
function get_subscribed_lists($email)
{
$list = array();
$query = "select lists.listid, listname from sub_lists, lists
where email='$email' and lists.listid = sub_lists.listid
order by listname";
if(db_connect())
{
$result = mysql_query($query);
if(!$result)
echo '<p>Unable to get list from database.';
$num = mysql_numrows($result);
for($i = 0; $i<$num; $i++)
{
array_push($list, array(mysql_result($result, $i, 0),
mysql_result($result, $i, 1)));
}
}
return $list;
}
//get the lists that this user is *not* subscribed to
function get_unsubscribed_lists($email)
{
$list = array();
$query = "select lists.listid, listname, email from lists left join sub_lists
on lists.listid = sub_lists.listid
and email='$email' where email is NULL order by listname";
if(db_connect())
{
$result = mysql_query($query);
if(!$result)
echo...
4 Respuestas
Respuesta de llarensj
1
Respuesta de marcoscasill
1
Respuesta de reynierpm
1
Respuesta de jecomas
1