Solved

PEAR unable to process query

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Making API calls from hashed passwords 26 52
Attach to file (img) a unique id 8 24
PHP not parsing ' character 12 37
Cookie not unsetting 7 18
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

785 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