Solved

PEAR unable to process query

Posted on 2004-04-02
2
378 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
  • 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now