Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PEAR unable to process query

Posted on 2004-04-02
2
Medium Priority
?
398 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 750 total points
ID: 10745424
should it be $db
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

719 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