Link to home
Start Free TrialLog in
Avatar of duficy
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/ajrassociates.com/httpdocs/mail_update.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_FETCH_MODE_ASSOC))
{
////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().'Successfully updated database.';
 }
  header( "Location:" );
?>
</body>
</html>
Avatar of venkateshwarr
venkateshwarr

where is  $sql defined?

I think your php script is not recognizing the variable.

ASKER CERTIFIED SOLUTION
Avatar of venkateshwarr
venkateshwarr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial