Call To Undefined Method Database::prepare()

Sep 15, 2010

from [URL]

[Code]....

What have I done wrong, or was this example code wrong? Call to undefined method Database::prepare() on line 167

ADVERTISEMENT

Class - Method Call Reports Error About Undefined Method

Feb 26, 2011

I believe my class is correct but when I try to echo the output of the class I get an error on line 28: the line " echo 'Your full name ...." is line 28.

<?php
echo 'Your full name is ' . $person->retrieve_full_name() . '.';
?>

This is where I created the function "retrieve_full_name"

public function __retrieve_full_name() {
$fullname = $this->firstname . ' . ' . $this->lastname;
return $fullname;
}/* This ends the Full Name Function*/

the error I get is Fatal error: Call to undefined method stdClass::retrieve_full_name() in /home/mjcrawle/processlogin2.php on line 28

View 3 Replies View Related

Call To Undefined Method DateTime - Add Method?

Oct 15, 2010

I am using php 5.2.9 as a part of xampp installation. I am using codeigniter framework for my webapp. When I call upon DateTime::add, the Call to undefined method error is displayed. My code is...

$date_now = new DateTime();
$formatted_date = $date_now->format('Y-m-d H:i:s');
$expiry_date = $date_now->add(new DateInterval('P1Y'));
The error being displayed is...
Fatal error: Call to undefined method DateTime::add() in C:webappsfirstsystemapplicationmodelsmodel_first.php on line 25

How can I resolve this? The DateTime::format method works fine here.

View 1 Replies View Related

"Call To Undefined Method" Error When Calling Static Method From Parent

Jun 24, 2010

How is the correct way to call a child class method from a parent class if both are static?

When I use static classes it returns the error "Call to undefined method A::multi()", however when I use non-static methods there is no problem, for example:

class A {
public static function calc($a,$b) {
return self::multi($a, $b);
}
}

[Code]....

Is there a way to call a child static method without knowing its class name?

View 1 Replies View Related

PDO: Call To Undefined Method DB::query()

Jun 10, 2011

Trying to get to hang of PDO but not having much fun at the moment. I bet it's something really simple as well.

EDIT: What would be a better way to go about doing this? i.e instead of wrapping it in a class?

classes/DB.class.php:
<?php
// DB.class.php
class DB {
protected $db_name = "PDO";
protected $db_user = "root";
protected $db_pass = "root";

[Code]....

View 5 Replies View Related

Call To Undefined Method Mysqli_stmt?

Sep 14, 2009

I am currently trying to convert my PHP Website statemets from the old mysql to mysqli and use prepared statements. I use Eclipse with PDT and a ZendDebugger on a Windows 7 OS with IIS 7. The following code produces the following error: Call to undefined method mysqli_stmt::bindParam()

Code:
$stmt = $GLOBALS['f_dbLink'] -> prepare("SELECT post_text, bbcode_uid
FROM phpbb3_topics t, phpbb3_posts p, phpbb3_users u
WHERE t.forum_id = ? AND t.topic_id = ?
AND topic_first_post_id = post_id AND topic_first_poster_name = username");
$stmt->bindParam(1, $GLOBALS['contentForumID']);
$stmt->bindParam(2, $GLOBALS['contentID']);
$stmt -> execute();

The $stmt is created successfully as far as I can tell from the Debugger.

View 4 Replies View Related

Fatal Error: Call To Undefined Method?

Apr 24, 2011

I am having this error Fatal error: Call to undefined method RecursiveArrayIterator::fetch_array() on line 128

$hierachy = new hierachy;
$iterator = new RecursiveIteratorIterator(new recursiveArrayIterator($hierachy->getSamelevelNode($name1)));
[code]....

View 1 Replies View Related

Error: Call To Undefined Method Foo::stuff() In

May 5, 2011

I'm trying to learn this MVC OOP thingie and I stumbled across a weird error:

Fatal error: Call to undefined method Foo::stuff() in ...

The code I have:
class Foo extends FooBase{
static $_instance;
private $_stuff;
public function getStuff($which = false){
if($which) return self::app()->_stuff[$which]; else return self::app()->_stuff;
}
public function setStuff($stuff){

[Code]...

So if I understand correctly, a getter function can not have arguments? Why? Or am I doing something wrong here?

View 1 Replies View Related

Call To Undefined Method When It's Static And Exists?

Nov 9, 2010

php > require_once('System.php');
php > System::users();
PHP Fatal error: Call to undefined method System::users() in php shell code on line 1

This seems to happen both from interactive command-line and from the a simple script:

<?php
require_once('System.php');
var_dump(System::users());
?>
System.php is in the PHP include path - and includes properly:

[Code].....

View 2 Replies View Related

Catching A Call To An Undefined Static Method?

Aug 16, 2009

I have a class which just contains static methods.If make a typo and call a method from that class that does not exist, how can I catch that error?

PHP Code:
class Foo {
static function bar (){}
function __call($method, $a = 0){[code]....

View 6 Replies View Related

Call To Undefined Method SimpleXMLElement - Fatal Error

Apr 26, 2011

i am having a code which parses the xml text which is obtained from google search it used to working fine before , I think after updating my version infos it not working fine what might be the problem i am getting the following error Fatal error: Call to undefined method SimpleXMLElement::child_nodes() in /home/search.php in line 70 let me know how can i solve this problem This code is used in smarty And it gets the response string from curl.

View 2 Replies View Related

Error: Call To Undefined Method Mysqli_stmt::query()

Jan 10, 2011

Possible Duplicate:Fatal error: Call to undefined method mysqli_stmt::query()

I'm getting the above error message, could you find out why?

$mysqli=new mysqli("localhost", "***", "***","***") or die($mysqli->connect_error);

function checklogin($username, $password){
global $mysqli;
$result = $mysqli->prepare("SELECT * FROM users WHERE username = ?");
$result->bind_param("s", $username);
$result->execute();
if($result != false){
$dbArray=$result->fetch_array();

View 1 Replies View Related

Fatal Error: Call To Undefined Method PDO::close()

Apr 24, 2011

i have got that error and the line was this :

public function __destruct() {
$this->db->close();
}

i use PDO, is this the problem, does the PDO driver don't recognize this function? if yes, what is its equivalent in PDO ?

View 5 Replies View Related

Joomla Module Development To Get Call To Undefined Method?

Jan 15, 2010

I've been trying to get my first module to work, but keep getting Fatal error: Call to undefined method JDocumentRendererModule::isTuesday() and can't for the life of me figure out what is wrong. I think I followed all tutorials to the letter, however as I am not really comfortable with PHP,

Joomla Version 1.5.15
PHP 5.2.11 / 5.3.1 for testinghere is my code...
mod_jjoz_tourdates.php
[code]....

View 1 Replies View Related

Fatal Error: Call To Undefined Method After Uploading On The Web?

Mar 6, 2010

I have some pages, which work fine locally(using WAMP and error_reporting E_ALL in php.ini), but once I upload them, I get the following error:

Fatal error: Call to undefined method DB::exists()

The method is there, and I don't know why it can't be seen.

View 5 Replies View Related

Run GeneratePassword() - Error Call To Undefined Method Forgotpass

Jan 19, 2010

I am having problem with running generatePassword() Its comes up with the error: Call to undefined method forgotpass::generatePassword()

<?php
class forgotpass extends functions
{
function forgotpass($post)   //For forgot password.
{    
$newpass = $this->generatePassword(8);
$sql_select = "select * from tbladmin where admin_name = '".$post['username']."'";
$result_select = mysql_query($sql_select);
[Code]....

View 6 Replies View Related

Error: Call To Undefined Method DOMElement::importNode() In

Jun 2, 2011

Somthing wrong here, dont seem to be able to merge XML DOMDocumet's I get the error, "Fatal error: Call to undefined method DOMElement::importNode() in C:xampphtdocsxmltestxmltest.php on line 27" can anybody help me put this code right...

<?php
// include required files
include 'XML/Query2XML.php';
include 'MDB2.php';
// prepare xml document
$dom = new DomDocument('1.0');

[Code]...

View 1 Replies View Related

Error: Call To Undefined Method StdClass::display()

Mar 28, 2010

First, this is a smarty site. My job is to change the naming of some of the smarty files as well as other files, so the paths and all else is set right because the site worked before I started changing them. The site is loaded within a folder under the root folder. On the home page, or Public_html/Software Project/index.php I am getting this error.

Code:
Fatal error: Call to undefined method stdClass::display() in /home/russia6/public_html/Software Projects/Apex Framework/index.php on line 12
The index.php coding is
[CODE]
<?php
require_once("includes/config.php");
require_once("includes/connection.php");
require_once("includes/data.php");

[Code]...

View 3 Replies View Related

Fatal Error : Call To Undefined Method Log::setUserId() ?

Dec 17, 2009

I have a generic Logger class that looks like this:

class Logger {

...

public function add($userId, $siteId, $logTypeId, $message) {
$Log = LogMapper::create();

[code]....

I have two other classes, LogMapper and Log, which Logger uses to write records to a database.I also have a mechanism that emails me when a fatal error occurs. I received the following in about a dozen emails: Call to undefined method Log::setUserId()

My application uses autoloading, and I first thought that may be the problem, but clearly the Logger class is being loaded, and so autoloading has not broken. The path for the Log class is correct in the autoloader...and clearly the Log class has been loaded--otherwise a "Class 'Log' not found" error would have been thrown.

View 6 Replies View Related

Fatal Error: Call To Undefined Method Session?

Jun 4, 2010

Fatal error: Call to undefined method Session::ismod() in /home/a1535619/public_html/main.php on line 38

Code: [Select]   ."[<a href="userinfo.php?user=$session->username">My Account</a>]   "
."[<a href="useredit.php">Edit Account</a>]   ";
   if($session->isAdmin()){
 echo "[<a href="admin.php">Admin Center</a>]   "

[code]....

View 5 Replies View Related

XML_RPC_Response Fatal Error: Call To Undefined Method Kindof

May 16, 2007

I am new to php5 programming :)

I redirect users to another server to login. After they login
successfully, they will be redirected to test.php. The server provides
xml_rpc interface so I can communicate with it. After running my
scripts, I get this error:

Fatal error: Call to undefined method XML_RPC_Response::kindOf() in /
usr/share/PEAR/XML/RPC.php on line 1972

It seems it is these two lines that cause problems:

I do get some response from the server, though.

The followings are my scripts:

test.php

<?php

error_reporting(E_ALL);
ini_set('display_errors', true);

include("cwl.php");

$test=new cwl();

$test->test();

?>

cwl.php

<?php

require 'XML/RPC.php'
error_reporting(E_ALL);
ini_set('display_errors', true);

class cwl{

private $cwlURL;
private $xmlrpcPath;
private $appID;
private $appIDPassword;
private $cwlClient;
private $sessionTicket;
private $params;.....

View 3 Replies View Related

Trying To Install Auth For CI: Call To Undefined Method CI_Loader::setdata()?

Dec 31, 2010

I have been trying to implement an auth system for Codeigniter. I wanted to save time, though it hasn't succeeded so far.The system I'm trying to implement is: [url].....

Currently I have some forms working, but the registration form generates a fatal error:

PHP Fatal error: Call to undefined method CI_Loader::setdata() in /Applications/MAMP/htdocs/CI+Login/system/application/controllers/auth.php on line 159

Anyone has got this system running?

EDIT:The code that generates the error is:

if ($this->config->item('auth_use_security_code'))
$this->authlib->register_init();
$data['countries'] = $this->Usermodel->getCountries();
$this->load->setdata($data);

The problem is that load does not contain a method named setdata, has it in a previous version of CI or what can I make of this?

View 1 Replies View Related

Fatal Error: Call To Undefined Method Mysqli_stmt::fetch_array()

Apr 13, 2011

in this code i get the error: Fatal error: Call to undefined method mysqli_stmt::fetch_array()

What is the problem?

$search= "player";
($sql = $db->prepare('select job from jobs where job like ?'));
$sql->bind_param('s', $search);
$sql->execute();
$sql->bind_result($search);

[Code]////

View 2 Replies View Related

Fatal Error: Call To Undefined Method SplFileInfo::getRealPath()?

Apr 26, 2011

I've got a client who has just set up a new VPN and is attempting to install my plugin.He's getting the following error:Fatal error: Call to undefined method SplFileInfo::getRealPath() on the commented line below. This appears to have something to do with the ZEND libraries. Any ideas what I should tell him to do?

View 1 Replies View Related

Class - Uncaught SoapFault Exception: Call To Undefined Method?

Mar 28, 2011

I'm trying to make a very small SOAP system working, but I'm struggling with a (small) problem for a few days What I want to do: I want to do some things on a few variables, which I'm passing in a class. Problem: I want to use the incoming class on my server.php file as an Object. But that's not possible.My server PHP file:

class Lid
{
public $NumberOfYears; //this one is public for example purpose only
[code]....

View 2 Replies View Related

Fatal Error: Call To Undefined Method Date::shortYear()

Jul 12, 2010

This line of code:

echo "<strong> {$this->author->last} {$this->date->shortYear()}</strong> ...";

gives me this error: Fatal error: Call to undefined method Date::shortYear() in /f5/debate/public/libs/Card.php on line 22. Even though in Date.php (which is included in Card.php):

class Date {
public $day;
public $month;
public $year;
public function shortYear() {
return substr($this->year, -2);
}
}

View 2 Replies View Related

Fatal Error: Call To Undefined Method Net_SMTP::getGreeting()

Nov 3, 2010

I get this error when sending emails with the PEAR Net_SMTP module:

Fatal error: Call to undefined method Net_SMTP::getGreeting() in /home/test/Mail/smtp.php on line 316

View 1 Replies View Related

QuoteFatal Error: Call To Undefined Method Mysqli_result::fetch_all()

Nov 17, 2010

I have an error that I seem to find curious. Let me explain what I have. I have a Database class that has a function (the culprit) that is called fetchAll. It is suppose to call the mysqli method mysqli_result::fetch_all(). This method does exist, I have looked it up: The PHP Manual, however do note the last comment on the page, it describes my problem, but does not explain how I can fix it. Now, here is my error:

QuoteFatal error: Call to undefined method mysqli_result::fetch_all() in /var/www/core/includes/Database.php on line 36 Here is line 36:
$row = $this->result->fetch_all($mode);

Here is the entire function, or is it called a method since it is in a class?

[code]...

View 14 Replies View Related

Fatal Error: Call To Undefined Method CI_DB_mysql_driver::result() - CodeIgniter?

Nov 24, 2010

I have CodeIgniter error below,

Code:
function check_email()
[code]....

why is it when i include th result() method it show an error mesage?

View 3 Replies View Related

Swift Mailer With Kohana Wrapper - Fatal Error - Call To Undefined Method

Mar 19, 2010

My current code is this

$swift = email::connect();
$swift->setSubject('hello')
->setFrom(array('[URL]' => 'Alex'))
->setTo(array('[URL]'=> 'Alex'))
->setBody('hello')
->attach(Swift_Attachment::fromPath(DOCROOT . 'assets/attachments/instructions.pdf'));
$swift->send();

The email::connect() returns an instance of SwiftMailer. As per these docs, it would seem that it should work. However, I get an error Fatal error: Call to undefined method Swift_Mailer::setSubject() in /home/user/public_html/application/classes/controller/properties.php on line 45 I've seen that email::connect() does exactly what the example code in the docs does. That is include the correct file return an instance of the library What am I doing wrong?

View 1 Replies View Related

Passing Parameters In XML - Fatal Error: Call To Undefined Method XSLTProcessor::addParameter()

Jul 30, 2010

i'm trying to implement paging in xml using this code and got around to making it work. while it works perfectly, there is a small issue, that when i click on the NEXT button, it keeps reloading the page with the same initial records. it does not take the user to the next page.

i came across this link wherein the poster had a similar issue, and it seems from the answers parameters need to be passed. however, the guy in that link was using MM_XSLTransform, while i'm not. hence when i try to implement this code in index.php:

$xsl->addParameter("Page", $_GET["Page"]);
$xsl->addParameter("PageSize", $_GET["PageSize"]);

it throws an error:

Fatal error: Call to undefined method XSLTProcessor::addParameter()

UPDATED

php code:

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$xmldoc = new DOMDocument();
if(!file_exists('test.xml')){...............

View 1 Replies View Related

Give Error - Call To Undefined Method When Trying To Create Advanced Profile In Admin

Nov 23, 2010

Test conducted in Magento Enterprise version 1.9.0.0 First Problem When I try to create new profile under Advanced profile in admin and try to save it, I get following error:

Fatal error: Call to undefined method Mage_Adminhtml_Block_Widget::getrowurl() in D:wampwwwentappcodecoreMageAdminhtmlBlockWidgetGrid.php on line 1583

As I started to drill down into the code and reach to appcodecoreMageAdminhtmlBlockWidgetGrid.php in line no. 1583, I have found following chunk of code (green color):

[code]...

If you see $res = parent::getRowUrl($item); In the code, it instruct to run getRowUrl() function from its parent class i.e. Mage_Adminhtml_Block_Widget. Now when I search getRowUrl function in the widget class, it is not available there, even not in the parent class of Mage_Adminhtml_Block_Widget. I also tried to debug by commenting the code written getRowUrl() function, but it doesn't work.

Second problem: When I run normal profile to import all product, I see following error

Fatal error: Call to undefined method Mage_Adminhtml_Block_Abstract::getexceptions() in D:wampwwwentappcodecoreMageAdminhtmlBlockSystemConvertProfileRun.php on line 166

All I tested this in fresh enterprise version 1.9.0.0 without installing any extensions.

View 2 Replies View Related

Overide Parent Function In Stub - Fatal Error: Call To Undefined Method DbConnect?

May 25, 2011

This is probably an easy one for some of you. I'm trying to test a protected method on a small DB connection class I have. Relevant code is as follows:

class DbConnect{

/**
* Connexion MSSQL local[code]....

To test the method, I had the bright idea (probably from a post here somewhere) to subclass and call from there. I created a subclass, right at bottom of my test file. I obviously could not override the visibility of the method to public, so decided another approach in the stub: declare a public method that calls the parent's protected localConnect method:

class DBConnectStub extends DBconnect{
public function callLocalConnect($localConfig){
parent::localConnect($localConfig);[code]...
The weird part, when I run the test, php spits out:

Fatal error: Call to undefined method DbConnect::callLocalConnect() in C: irelinkCRMsync est
irelinkCRMSyncDBConnectTest.php on line 82.

The object is properly instanciated, but why is the method not defined, surely there is a detail that has eluded me. Is this approach valid or is there a better way?

View 2 Replies View Related

CakePHP - Getting "Call To Undefined Method" For Created Component

Jun 10, 2011

Background: I'm working on a plugin for CakePHP that uses an email provider's API to send out emails rather than the built in EmailComponent that comes with CakePHP. The issue is that I have mirrored the code from EmailComponent, and removed any unnecessary functions as well as adding a few of my own. Aside from not being able to add a reset() function, the other major issue I am having is this error:

Fatal error: Call to undefined method PostageComponent::send() in /app/controllers/posts_controller.php on line 50 Here's the code I used to set add it to my controller:

var $components = array('Session', 'Postage');
function email() {
$this->Postage->from = 'from@email.com';
$this->Postage->to = 'recipient@email.com';
$this->Postage->subject = 'this is the subject';
$this->Postage->template = 'TEMPLATE_NAME';
$result = $this->Postage->send();
$this->log($result, 'debug');
}

And I am just completely baffled. I'm not exactly a CakePHP expert, but I figured I should be able to figure this out. EDIT: I think we just found it - a stray } that was closing the class before the definition of the methods. Seriously.

View 2 Replies View Related

"Call To Undefined Method" Error When Calling Invoke From Class Variable

Jun 24, 2010

I have been doing some tests (to replace old code) with the __invoke magic method and I'm not sure this is a bug or not:

Lets suppose we have a class:

class Calc {
function __invoke($a,$b){
return $a*$b;
}

[Code].....

The error occurs when we try to call it like:

$t = new Test;
echo $t->k(4,5); //Error: Call to undefined method Test::k()

I know that a "solution" could be to have a function inside the class Test (named k) to "forward" the call using call_user_func_array but that is not elegant.

I need to keep that instance inside a common class (for design purposes) and be able to call it as function from other classes..

Update:

I found something interesting (at least for my purposes):

If we assign the "class variable" into a local variable it works:

$t = new Test;
$m = $t->k;
echo $m(4,5);

View 3 Replies View Related

Resolving Fatal Error: Call To Undefined Method Facebook::getSession() During Facebook Authentication?

May 25, 2011

i am currently working on facebook connect login page for my web page.but i keep receiving 'call to undefined method' error message at line 24:

$session = $facebook->getSession();

when i remove line 24 everything seems to run smoothly . as i am following a tutorial at

http:[url]...and.html and http:[url]....the error message is

Fatal error: Call to undefined method Facebook::getSession() in C:xampphtdocskiteindex.php on line 24

here is my code:

<?php session_start();
//config
include "resources/Connections/kite.php";[code]....

View 1 Replies View Related

Error "Call To Undefined Method DB::Connect()" With Pear Database Connection

Oct 21, 2009

I am using php pear connectivity. I have following DB.php file.

HP Code:
<?php
class DB
{
var $handle;
var $host;
var $port;
var $name;
[Code]...

Bit this return me following fatal error. Fatal error: Call to undefined method DB::Connect() in D:xampphtdocsm4scommentsindex.php on line 12

View 4 Replies View Related

Write Form Data Into An Excel Sheet - Error "Call To Undefined Method PEAR_Error::setColumn()"

Sep 16, 2009

i am using 'Spreadsheet excel writer' to write form data into an excel sheet. below is my code snippet, uses to add worksheets, iam getting an error, which is really breaking me.

Code: [Select]<?php
$xml = simplexml_load_file("featureDetail.xml");
require_once 'Spreadsheet/Excel/Writer.php';
$excel = new Spreadsheet_Excel_Writer();
$sheet =& $excel->addWorksheet('Home');
$sheet->setColumn(0,0,29);
foreach($xml->FEATURE as $feature)
[Code]....

Fatal error: Call to undefined method PEAR_Error::setColumn() in D:xampphtdocsRelease9.0example.php on line 14

View 2 Replies View Related

Getting Error: Fatal Error: Call To Undefined Method

Sep 20, 2010

I'm running this code:

$db = new Mongo("[URL]...;
$collection = $db->foobar;
$collection->insert($content);

I'm trying to test mongohq by just creating a random collection. I'm getting this error: Fatal error: Call to undefined method MongoDB::insert() in /ajax/db.php on line 24. I have the client installed as far as I know: I'm also running php 5.2.6. What's the problem?

View 1 Replies View Related

Php 5 Call To Member Function Prepare() On A Non Object Error

Jan 3, 2008

When I run a small test script I get the following error.
___________________________
PHP Fatal error: Call to a member function prepare() on a non-object
in /usr/local/lib/php5/pg_connect .php on line 73....

View 3 Replies View Related

Call To A Member Function Prepare() On A Non-object Error?

Sep 5, 2010

This is the code I'm using to pass the database handle to my class:

$db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($db->connect_error)
die('MySQL connection error (' . $db->connect_errno . ') ' . $db->connect_error); [code]...

And this is the code in the Linkgen class:

class Linkgen {
private $db; // our database handle
private $linksLeft;[code]...

For some reason I get the non-object error when I call the getLinksLeft method. I can't figure this out because from what I can see I'm referencing the database handle correctly.

View 1 Replies View Related

Mysqli - Call To A Member Function Prepare() On A Non-object?

Dec 16, 2010

I am trying to write a PHP function. It is very simple. It is just a prepared statement that queries the database, but I can not get this to work. I keep recieving the error Call to a member function prepare() on a non-object. here is the code:

$DBH = new mysqli("host", "test", "123456", "dbname");
function selectInfo($limit, $offset){
$stmt = $DBH->prepare("SELECT * FROM information LIMIT ?,?");
$stmt->bind_param("ii", $limit, $offset);
$stmt->execute();
}
selectInfo();

Any time I call the function i get that error.

View 7 Replies View Related

Fatal Error - Call To Member Function Prepare() On Non Object

Feb 6, 2011

So the scenario is simple. I use class that does something in database but in that class I call another class that also does something in DB. include_once changed to include and it works This is what I get: Fatal error: Call to a member function prepare() on a non-object -> mLog.php on line 20 I use db_config.php to create PDO object and then include it in my classes.

[Code....]

View 2 Replies View Related

Fatal Error: Call To A Member Function Prepare() On A Non-object?

Mar 21, 2011

i have a fatal error in my code, Fatal error: Call to a member function prepare() on a non-object in ... on line 28Updated code:

<?
function check($sql, $db, $email, $pwdHasher, $hash, $userExists, $sendPass ) {
if(!empty($_POST['email']) && validateEmail($email)) {
[code....

View 2 Replies View Related

Fatal Error: Call To A Member Function Prepare() On A Non-object

Dec 6, 2010

Fatal error: Call to a member function prepare() on a non-object

Is what I am getting when I try to do:

$sql = $connect->prepare ("SELECT id, pwd, firstname, lastname, approved, user_level FROM users WHERE $user_cond AND banned = 0"); // SELECT
$sql->execute ();
$sql->setFetchMode(PDO::FETCH_ASSOC);
$num = $connect->rowCount();

Im holding on rewriting my system, taking out all mysql_* and make use of pdo instead. This is what was before:

$result = mysql_query("SELECT `id`,`pwd`,`firstname`,`lastname`,`approved`,`user_level` FROM users WHERE
$user_cond
AND `banned` = '0'
") or die (mysql_error());
$num = mysql_num_rows($result);

And with list() I have:

list($id,$pwd,$firstname,$lastname,$approved,$user_level) = mysql_fetch_row($result);

instead of mysql_fetch_row($result); what should I do in PDO? My PDO object/connection:

try{
$connect = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME.";charset:UTF-8", DB_USER, DB_PASS, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));

[code]....

View 4 Replies View Related

ADVERTISEMENT