Solved

PEAR unable to process query

Posted on 2004-04-02
2
396 Views
Last Modified: 2010-05-18
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>
0
Comment
Question by:duficy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10745420
where is  $sql defined?

I think your php script is not recognizing the variable.

0
 
LVL 12

Accepted Solution

by:
venkateshwarr earned 250 total points
ID: 10745424
should it be $db
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question