duficy
asked on
PEAR unable to process query
Below is the error message I get when I run my PHP/pear webpage. The query works if run as a separate SQL query. Also the update query doesn't increment. Other PEAR pages work.
Thanks.
>>>ERROR MESSAGE<<<
Fatal error: Call to a member function on a non-object in /home/httpd/vhosts/ajrasso ciates.com /httpdocs/ mail_updat e.php on line 30
>>>ERROR MESSAGE<<
>>>>>PHP CODE<<<<<<<<<<<
<html>
<head>
<title>mail_update</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
require_once 'DB.php';
$dsn = array(
'phptype' => 'mysql',
'username' => 'XXXXXXX',
'password' => 'XXXXXXX',
'hostspec' => 'localhost',
'database' => '',
);
$db =& DB::connect($dsn);
if (DB::isError($db)) {
die($db->getMessage());
}
$part[1] = "message 1";
$part[2] = "message 2";
$part[3] = "message 3";
$part[4] = "message 4";
$part[5] = "message 5";
$part[6] = "message 6";
$result = $sql->query("SELECT * FROM mailform WHERE part < 7");
while ( $subscriber = $result->fetcharray(DB_FET CH_MODE_AS SOC))
{
////mail( "someone@cshore.com", "AJR 6 Day Course Sign-up",
// "Name: $name\nEmail: $email\nHas registered for the FREE 6 Day Course\n\n\n", "From: $email" );
$query = "UPDATE mailform SET part='++$subscriber[part]' WHERE id='$subscriber[id]'";
$result = mysql_query($query);
if ($result)
echo mysql_affected_rows().'Suc cessfully updated database.';
}
header( "Location:" );
?>
</body>
</html>
Thanks.
>>>ERROR MESSAGE<<<
Fatal error: Call to a member function on a non-object in /home/httpd/vhosts/ajrasso
>>>ERROR MESSAGE<<
>>>>>PHP CODE<<<<<<<<<<<
<html>
<head>
<title>mail_update</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
require_once 'DB.php';
$dsn = array(
'phptype' => 'mysql',
'username' => 'XXXXXXX',
'password' => 'XXXXXXX',
'hostspec' => 'localhost',
'database' => '',
);
$db =& DB::connect($dsn);
if (DB::isError($db)) {
die($db->getMessage());
}
$part[1] = "message 1";
$part[2] = "message 2";
$part[3] = "message 3";
$part[4] = "message 4";
$part[5] = "message 5";
$part[6] = "message 6";
$result = $sql->query("SELECT * FROM mailform WHERE part < 7");
while ( $subscriber = $result->fetcharray(DB_FET
{
////mail( "someone@cshore.com", "AJR 6 Day Course Sign-up",
// "Name: $name\nEmail: $email\nHas registered for the FREE 6 Day Course\n\n\n", "From: $email" );
$query = "UPDATE mailform SET part='++$subscriber[part]'
$result = mysql_query($query);
if ($result)
echo mysql_affected_rows().'Suc
}
header( "Location:" );
?>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think your php script is not recognizing the variable.