PHP - Moved: Call To Undefined Method Database::onconnect()
This topic has been moved to Third Party PHP Scripts.
http://www.phpfreaks.com/forums/index.php?topic=321957.0 Similar TutorialsI have a class called cid which contains these functions: Code: [Select] public function UpdateDeliveryAddress($orderNumber, $deliveryaddress) { $sql = "UPDATE `CIDOrders` SET `DeliveryAddress` = '" . mysql_real_escape_string($deliveryaddress) . "' WHERE `CIDOrderNumber` = " . $orderNumber . ";"; mysql_select_db(DB_DATABASE_NAME, $this->conn); return mysql_query($sql, $this->conn); } public function UpdateInvoiceAddress($orderNumber, $invoiceAddress) { $sql = "UPDATE `CIDOrders` SET `InvoiceAddress` = '" . mysql_real_escape_string($invoiceaddress) . "' WHERE `CIDOrderNumber` = " . $orderNumber . ";"; mysql_select_db(DB_DATABASE_NAME, $this->conn); return mysql_query($sql, $this->conn); } It is called in a page called create order. Code: [Select] / Add a new delivery address to the order $cid->UpdateDeliveryAddress($_POST['orderNumber'], $_POST['deliveryaddress']); // Add invoice address to the order $cid->UpdateInvoiceAddress($_POST['orderNumber'], $_POST['invoiceaddress']); I get a call to undefined method error. Can anyone help me. thank you Well I have a library file class_database.php which defines a class called 'database' and a method called 'get' to retrieve database info. It was originally designed to return a two-dimensional array with the format of $array['index']['associative']. Right now I want to change this so as to return a result, which can then be used in other script files to retrieve data by using the fetch_array() method after getting this result. It doesnt work though, and I got this error 'Call to undefined method mysqli_stmt::get_result()', which confuses me... The two methods get() and _buildQuery are shown below, please help me figure out how to return an Mysql result so that I can use while($row = $db->get()->fetch_array()) on it with flexibility... The method get() Code: [Select] public function get($tableName, $numRows = NULL) { $this->_query = "SELECT * FROM $tableName"; $stmt = $this->_buildQuery($numRows); $stmt->execute(); $results = $stmt->get_result(); $this->reset(); return $results; } The method _buildQuery is shown below: Code: [Select] protected function _buildQuery($numRows = NULL, $tableData = NULL) { (gettype($tableData) === 'array') ? $hasTableData = true : $hasTableData = false; (!empty($this->_where )) ? $hasConditional = true : $hasConditional = false; // Did the user call the "where" method? if (!empty($this->_where)) { // if update data was passed, filter through and create the SQL query, accordingly. if ($hasTableData) { $i = 1; $pos = strpos($this->_query, 'UPDATE'); if ( $pos !== false) { foreach ($tableData as $prop => $value) { // determines what data type the item is, for binding purposes. $this->_paramTypeList .= $this->_determineType($value); // prepares the reset of the SQL query. ($i === count($tableData)) ? $this->_query .= $prop . ' = ?': $this->_query .= $prop . ' = ?, '; $i++; } } } //Prepair the where portion of the query $this->_query .= ' WHERE '; $i = 1; foreach ($this->_where as $column => $value) { // Determines what data type the where column is, for binding purposes. $this->_whereTypeList .= $this->_determineType($value); // Prepares the reset of the SQL query. ($i === count($this->_where)) ? $this->_query .= $column . ' = ?': $this->_query .= $column . ' = ? AND '; $i++; } } // Determine if is INSERT query if ($hasTableData) { $pos = strpos($this->_query, 'INSERT'); if ($pos !== false) { //is insert statement $keys = array_keys($tableData); $values = array_values($tableData); $num = count($keys); // wrap values in quotes foreach ($values as $key => $val) { $values[$key] = "'{$val}'"; $this->_paramTypeList .= $this->_determineType($val); } $this->_query .= '(' . implode($keys, ', ') . ')'; $this->_query .= ' VALUES('; while ($num !== 0) { ($num !== 1) ? $this->_query .= '?, ' : $this->_query .= '?)'; $num--; } } } // Did the user set a limit if (isset($numRows)) { $this->_query .= " LIMIT " . (int) $numRows; } // Prepare query $stmt = $this->_prepareQuery(); // Prepare table data bind parameters if ($hasTableData) { $this->_bindParams[0] = $this->_paramTypeList; foreach ($tableData as $prop => $val) { array_push($this->_bindParams, &$tableData[$prop]); } } // Prepare where condition bind parameters if($hasConditional) { if ($this->_where) { $this->_bindParams[0] .= $this->_whereTypeList; foreach ($this->_where as $prop => $val) { array_push($this->_bindParams, &$this->_where[$prop]); } } } // Bind parameters to statment if ($hasTableData || $hasConditional){ call_user_func_array(array($stmt, 'bind_param'), $this->_bindParams); } return $stmt; } class MyDisplay { function displayToday() { $today = "Thursday"; { echo $today; } } function displayTomorrow() { $tomorrow = "Friday"; { echo $tomorrow; } } } $disp = new MyDisplay(); echo $disp->displayToday(); echo displayTomorrow();//fails is I have $disp->I simplified my code for explanation. One class with two methods. When I try to use the method I get this error. Fatal error: Call to undefined method MyDisplay::displayTomorrow() Edited by mallen, 05 June 2014 - 02:46 PM. So I have this code that generates a random ID class Session { var $username; //Username given on sign-up var $userid; //Random value generated on current login ... ... function Session(){ $this->time = time(); $this->startSession(); } ... ... $this->userid = $_SESSION['userid'] = $this->generateRandID(); ... ... function generateRandID(){ return md5($this->generateRandStr(16)); } and when it runs i get this error... Fatal error: Call to undefined method Session::generateRandID() Any ideas? HI guys, 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. can u please have a look at this, and help 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) { global $excel; $value=html_entity_decode($feature->NAME); echo " Value = $value"; echo "<br>"; $sheet123 =& $excel->addWorksheet('$value'); $sheet123->setColumn(0,0,29); } foreach($xml->FEATURE as $feature) { $sheet =& $excel->addWorksheet(html_entity_decode($feature->NAME)); $sheet->setColumn(0,0,29); } ?> Fatal error: Call to undefined method PEAR_Error::setColumn() in D:\xampp\htdocs\Release9.0\example.php on line 14 So i read the docs on this and it said to create a callback function and use ini_set to set the function. I am trying to serialize an array with the class inside the array Code: [Select] $dd_normal_button = array ( 'dd_normal_button_display' => array ( 'dd_button_digg' => __PHP_Incomplete_Class::__set_state(array( '__PHP_Incomplete_Class_Name' => 'DD_Digg', 'buttonLayout' => array ( 'Wide' => 'DiggWide', 'Normal' => 'DiggMedium', 'Compact' => 'DiggCompact', 'Icon' => 'DiggIcon', ), ) ) ) ); So then I try Code: [Select] serialize($dd_normal_button); and I get the error. Any ideas/suggestions. Thanks Hello, I have no idea where to post this but basically I am trying to create a facebook application using a "Building Facebook Applications For Dummies" book but I am stuck on the first paragraph! This is the appinclude.php file: Code: [Select] <?php require_once '../client/facebook.php'; // *** Add your Facebook API Key, Secret Key, and Callback URL here *** $appapikey = '<xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>'; $appsecret = '<xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>'; $appcallbackurl = '<http://projectstratos.com/facebook/live/>'; // Connect to Facebook, retrieve user $facebook = new Facebook($appapikey, $appsecret); // $user = $facebook->require_login(); OLD $user = $facebook->get_loggedin_user(); $is_logged_out = !$user; // Exception handler for invalid session_keys try { // If app is not added, then attempt to add if (!$facebook->api_client->users_isAppAdded()) { $facebook->redirect($facebook->get_add_url()); } } catch (Exception $ex) { // Clear out cookies for app and redirect user to a login prompt $facebook->set_user(null, null); $facebook->redirect($appcallbackurl); } ?> And this is the index.php file: Code: [Select] <h1>Watch Project Stratos Live!</h1> <?php require_once 'appinclude.php'; echo "<p>Your user id is: $user</p>"; echo "<p>Your name is: <fb:name uid=\"$user\" useyou\"false\" /></p>"; echo "<p>You have several freinds: </p>"; $friends = $facebook->app_client->friends_get(); echo "<ul>"; foreach ($friends as $friend) { echo "<li><fb:name uid=\"$freind\" useyou\"false\" /></li>"; } echo "</ul>"; ?> The facebook.php is the current fbml version (v2.1.2-4 I think) and the content in the h1 tag is echoed however after that there is the following errror message: Code: [Select] Fatal error: Call to undefined method Facebook::get_loggedin_user() in /xxxxxx/xxxxxx/xxxxxx/xxxx/xxxxxxxxxxxxxxxxxxxxxx/facebook/live/appinclude.php on line 12 I have mo idea what the problem could be! I have tried changing get_loggedin_user to getUser() but I just get another error, this is aparently (according to another forum) because I "forgot" to add get_loggedin_user. Thanks in advance, Cameron Using simple mail.php script. Yet I am getting the dreaded Fatal error: Call to undefined method Mail::AddAttachment() in ... error
"Fatal error: Call to undefined method Mail::AddAttachment() in \\...\www\mail.php on line 59"
This is mail.php
<?php class Mail { var $parts; var $to; var $cc; var $bcc; var $from; var $headers; var $subject; var $body; var $html; var $host; var $port; function __construct() { $this->parts = array(); $this->to = ""; $this->cc = ""; $this->bcc = ""; $this->from = ""; $this->subject = ""; $this->body = ""; $this->headers = ""; $this->html = true; } function buildMultipart() { $boundry = "HKC".md5(uniqid(time())); $multipart = "Content-Type: multipart/mixed; boundary = \"$boundry\"\n\n"; $multipart .= "This is a MIME encoded message.\n\n--$boundry"; for($i = sizeof($this->parts)-1; $i >= 0; $i--) { $multipart .= "\n".$this->buildMessage($this->parts[$i])."--$boundry"; } return $multipart .= "--\n"; } function getMail($complete = true) { $mime = ""; if(!empty($this->from)) { $mime .= "From: ".$this->from."\n"; } if(!empty($this->headers)) { $mime .= $this->headers."\n"; } if($complete) { if(!empty($this->cc)) { $mime .= "Cc: ".$this->cc."\n"; } if(!empty($this->bcc)) { $mime .= "Bcc: ".$this->bcc."\n"; } if(!empty($this->subject)) { $mime .= "Subject: ".$this->subject."\n"; } } if(!empty($this->body)) { $this->AddAttachment($this->body,"",($this->html?"text/html":"text/plain")); } $mime .= "MIME-Version: 1.0\n".$this->buildMultipart(); return $mime; } function send() { if(!empty($this->cc)) { $mime = $this->getMail(true); } else { $mime = $this->getMail(false); } if(!empty($this->host)) { ini_set("SMTP",$this->host); } return mail($this->to,$this->subject,$this->body,$mime); } } ?>And this is the program that makes the call: <?php if (isset($_POST["email"])) { $email = $_POST["email"]; $email= str_replace("'", "''", $email); require_once('../database.php'); $sql="select fa_id,name from freeagents where email='".$email."'"; $emailSearch = mssqlquery($sql); if (!mssqlhasrows($emailSearch)) { mssqlclose(); header("Location: http://www.baltimorebeach.com"); exit(); } $row = mssqlfetchassoc($emailSearch); mssqlclose(); $salt=$row["fa_id"].".baltimorebeach."; $check=hash('ripemd160', $salt.$email); $strMailBody = <<<MAILBODY Hi $row[name], <br><br> A request was made to change your Baltimore beach volleyball free agent registration information. <br><br> If you want to update your registration information click on this link: http://www.baltimorebeach.com/FreeAgents/registerfreeagent.php?email=$email&check=$check <br><br> To remove your name from the Free Agent list deselect all the checkboxes when you update your information. MAILBODY; require_once('../mail.php'); $message = new Mail(); $message->from = "noreply@baltimorebeach.com"; $message->to = $email; $message->subject = "Baltimore Beach Volleyball Free Agent Registration Update Link"; $message->body = $strMailBody; $message->html = true; $message->send(); } ?> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> <style type="text/css"> label.error { color:red; } input.error { border:1px solid red; } </style> <script type="text/javascript"> $().ready(function () { // validate registration form on keyup and submit $("#emailform").validate({ rules: { email: { required: true, email: true } }, messages: { email: { required: "Please enter an email address", email: "Please enter a valid email address" } } }); }); </script> </head> <body> To update your free agent registration information enter your email to send yourself a baltimorebeach.com url link that will allow you to access your own registration details. <br> To remove yourself from the free agent list just deselect all the leagues you have previously selected when updating your information. <br> <br> <?php if (!isset($_POST["email"])) { ?> <form id="emailform" action="sendlink.php" method="post"> E-Mail: <input type="text" id="email" name="email" value=""/> <br> <input type="submit" id="sumbit" value="Send"> </form> <?php } else { echo "E-Mail Sent. "."You will receive an email with the update link at the email address your requested shortly"; } ?> </body> </html>I did not write this code, however the person who did is no longer available to me. I can't seem to figure out how to remove this error. Thanks so much! Hello, I've been following google maps with php/mysql turorial http://code.google.com/apis/maps/articles/phpsqlajax.html I've come to my phpsqlajax_genxml.php file which as the google code has it like this: <?php require("phpsqlajax_dbinfo.php"); // Start XML file, create parent node $doc = domxml_new_doc("1.0"); $node = $doc->create_element("markers"); $parnode = $doc->append_child($node); // Opens a connection to a MySQL server $connection=mysql_connect (localhost, $username, $password); if (!$connection) { die('Not connected : ' . mysql_error()); } // Set the active MySQL database $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } // Select all the rows in the markers table $query = "SELECT * FROM markers WHERE 1"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } header("Content-type: text/xml"); // Iterate through the rows, adding XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE $node = $doc->create_element("marker"); $newnode = $parnode->append_child($node); $newnode->set_attribute("name", $row['name']); $newnode->set_attribute("address", $row['address']); $newnode->set_attribute("lat", $row['lat']); $newnode->set_attribute("lng", $row['lng']); $newnode->set_attribute("type", $row['type']); } $xmlfile = $doc->dump_mem(); echo $xmlfile; ?> I started with this but was getting errors at line 1!! I looked around abit on the net and found i should change $doc = domxml_new_doc("1.0"); to this $doc = new DOMDocument('1.0'); Then i got errors abour creating the elements, i looke on php.net and it looked like i needed to change $node = $doc->create_element("markers"); $parnode = $doc->append_child($node); $newnode->set_attribute("name", $row['name']); To this: $node = $doc->createElement('markers'); $parnode = $doc->appendChild($node); $newnode->setAttribute ('name', $row['name']); This at least got my code further down the page until the very last statment: $xmlfile = $doc->dump_mem(); Here i'm getting this error "Fatal error: Call to undefined method DOMDocument::dump_mem()" along with "Warning: Cannot modify header information - headers already sent" I havent even looked at the warning i just tried to fix the fatal error. Again i looked around the web and forums and php.net and thought maybe i need to set the value to "true" but it still got a fatal error. I looked on php.net and in there examples for dump_mem() and they had the nodes set_attribute create_element and append_child. Which confused me as that was what i used originally just following the google script and that got me the error right away "Fatal error to undefined method DOMDocument::create" Can anybody point out whats going wrong? This is my script that I am using <?php require('connect.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <title>phpsqlajax_genxml.php</title> </head> <body> <?php // Start XML file, create parent node $doc = new DOMDocument('1.0'); $node = $doc->createElement('markers'); $parnode = $doc->appendChild($node); // Select all rows in markers table $query = "SELECT * FROM markers WHERE 1"; $result = mysql_query($query); if (!$result) { die ('Invalid query: ' . mysql_error()); } header('Content-type: text/xml'); // Iterate through the rows, addind xml nodes for each while ($row = mysql_fetch_assoc($result)) { // Add to XML document node $node = $doc->createElement('marker'); $newnode = $parnode->appendChild($node); $newnode->setAttribute ('name', $row['name']); $newnode->setAttribute ('address', $row['address']); $newnode->setAttribute ('lat', $row['lat']); $newnode->setAttribute ('lng', $row['lng']); $newnode->setAttribute ('type', $row['type']); } $xmlfile = $doc->dump_mem(); echo $xmlfile; ?> </body> </html> And the google code is on the link in posted in the messge also but this is theres both of which fail for Fatal errors either on the dump_mem() or new DOMDocument respecitvaley : <?php require("phpsqlajax_dbinfo.php"); // Start XML file, create parent node $doc = domxml_new_doc("1.0"); $node = $doc->create_element("markers"); $parnode = $doc->append_child($node); // Opens a connection to a MySQL server $connection=mysql_connect (localhost, $username, $password); if (!$connection) { die('Not connected : ' . mysql_error()); } // Set the active MySQL database $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } // Select all the rows in the markers table $query = "SELECT * FROM markers WHERE 1"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } header("Content-type: text/xml"); // Iterate through the rows, adding XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE $node = $doc->create_element("marker"); $newnode = $parnode->append_child($node); $newnode->set_attribute("name", $row['name']); $newnode->set_attribute("address", $row['address']); $newnode->set_attribute("lat", $row['lat']); $newnode->set_attribute("lng", $row['lng']); $newnode->set_attribute("type", $row['type']); } $xmlfile = $doc->dump_mem(); echo $xmlfile; ?> Thanks to anybody who can help me out This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=311501.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=345884.0 OVERVIEW: The code is about making call to the escreen web service using SOAP and Curl with client authentication required. Currently I am not getting any result only HTTP 403 and 500 errors. The call requires client authenticate cert to be on the callng site. CODE: $content = "<TicketRequest> <Version>1.0</Version> <Mode>Test</Mode> <CommitAction></CommitAction> <PartnerInfo> <UserName>xxxxxxxxxx</UserName> <Password>xxxxxxxxxxx</Password> </ PartnerInfo> <RequestorOrderID></RequestorOrderID> <CustomerIdentification> <IPAddress></IPAddress> <ClientAccount>xxxxxxxxxx</ClientAccount> <ClientSubAccount>xxxxxxxxxx</ClientSubAccount> <InternalAccount></InternalAccount> <ElectronicClientID></ElectronicClientID> </CustomerIdentification> <TicketAction> <Type></Type> <Params> <Param> <ID>4646</ID> <Value></Value> </Param> </Params> </TicketAction> </TicketRequest>"; $wsdl = "https://services.escreen.com/SingleSignOnStage/SingleSignOn.asmx"; $headers = array( "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Cache-Control: no-cache", "Pragma: no-cache", // "SOAPAction: \"\"", "Content-length: ".strlen($content), ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $wsdl); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_VERBOSE, '1'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $content); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '1'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '1'); //curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //curl_setopt($ch, CURLOPT_HTTPHEADER, array('SOAPAction: ""')); curl_setopt($ch, CURLOPT_CAPATH, '/home/pps/'); curl_setopt($ch, CURLOPT_CAINFO, '/home/pps/authority.pem'); curl_setopt($ch, CURLOPT_SSLCERT, 'PROTPLUSSOL_SSO.pem'); curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'xxxxxxxxxxxx'); $output = curl_exec($ch); // Check if any error occured if(curl_errno($ch)) { echo 'Error no : '.curl_errno($ch).' Curl error: ' . curl_error($ch); } print_r($output); QUESTIONS: 1. I need to call the RequestTicket method and pass the XML string to it. I don't know how to do it here(pass the method name to call). 2. For client authentication they gave us three certs, one root cert, one intermediate cert and a client authentication cert PROTPLUSSOL_SSOpem(it was a .pfx file). Since we are on linux we converted them to pem . In curl calls I could not find way to how to include both the root cert and the intermediate cert ,so I combined them by making a new pem file and copying the intermediate cert and them the root cert and naming it authority.pem . I am not sure whether it works or not and would like your opinion. 3. For the current code Iam getting the error Error no : 77 Curl error: error setting certificate verify locations: CAfile: /home/pps/authority.pem CApath: /home/pps/ If I disable the curl error message,I am getting blank page with page title 403 - Forbidden. Access is denied. If I comment out the CURLOPT_CAPATH and CURLOPT_CAINFO lines it gives http 500 error page with the message as content and the following at the top. > HTTP/1.1 500 Internal Server Error. Cache-Control: private Content-Type: text/html Server: Microsoft-IIS/7.5 X-AspNet-Version: 1.1.4322 X-Powered-By: ASP.NET Date: Thu, 02 Sep 2010 14:46:38 GMT Content-Length: 1208 If I comment out as above and also CURLOPT_SSLCERT and CURLOPT_SSLCERTPASSWD it gives 403 error with the message as content. So I would request you to help me out by pointing out whats wrong with the current code. Thank you. This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=319682.0 Call to undefined method skin_register::show_lostpass_form() in /var/www/sources/reg.php on line 1042 1042: Code: [Select] $this->output = $this->html->show_lostpass_form(); my html function show_lostpass_form(); is Code: [Select] function show_lostpass_form_manual() { global $ibforums; return <<<EOF <div class="tablepad">{$ibforums->lang['dumb_text']}</div> <div class="pformstrip">{$ibforums->lang['complete_form']}</div> <table class="tablebasic"> <tr> <td class="pformleft"><strong>{$ibforums->lang['user_id']}</strong></td> <td class="pformright"><input type='text' size='32' maxlength='32' name='uid' class='forminput' /></td> </tr> <tr> <td class="pformleft"><strong>{$ibforums->lang['val_key']}</strong></td> <td class="pformright"><input type='text' size='32' maxlength='50' name='aid' class='forminput' /></td> </tr> EOF; } why this error not going away? :O 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: Quote Fatal 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? function fetchAll($mode = 'MYSQLI_ASSOC'){ $row = $this->result->fetch_all($mode); return !empty($row) ? $row : array();//if not empty return row, else return an array? } I could post the entire class, but I think it might be irrelevant so I will spear you guys. Do you guys think you might be able to help me out? Thanks! on line 53. Line 53 $ezdb->quick_insert('iid_ip', array('iid' => $_iid, 'ip' => $_ip)); The entire block of code /* Update table `iid_ip`. Between the dashed lines is the create statement used to create the image view count (iid_ip) table. ---------------------------------------- delimiter $$ CREATE TABLE `iid_ip` ( `iid` int(11) unsigned NOT NULL COMMENT 'Image id from where the count is the number of unique views.', `ip` varchar(15) NOT NULL COMMENT 'The ip of the visitor.', PRIMARY KEY (`iid`), KEY `ip` (`ip`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Table for view count of image using unique ip''s.'$$ ---------------------------------------- */// Escape variables that are used in the query. $_ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); $_iid = mysql_real_escape_string($imageid); // Count is 0 if ip has NOT seen the images, else count is 1 $_count = $ezdb->get_var("SELECT COUNT(*) FROM `iid_ip` WHERE `iid`='$_iid' AND `ip`='$_ip'"); if (!$_count) { // Insert the unique combination of image id and visitor ip in `iid_ip`. $ezdb->quick_insert('iid_ip', array('iid' => $_iid, 'ip' => $_ip)); } // Get count of image views. $_views = $ezdb->get_var("SELECT COUNT(*) FROM `iid_ip` WHERE `iid`='$_iid'"); // And format, thousands seperator is a comma, no decimals. $_views = number_format($_views, 0, '', ','); ///////////////////////////// I'm working on an application and it seems that the else block is being executed no matter what in the following if statement. My question (which seems really basic and like I should know the answer but I can't seem to remember) is if you have an object instance in an if statement, how does that resolve? Will it resolve to true because there is an object there? I assume/think that would be the behaviour but I can't remember. Also, I'll point out the class I'm working with is Zend_Mail. From my understanding the send method will return an instance of $this upon success and will throw an exception on failure. The mail is being sent but the else block is executing anyway. I may just throw it in a try catch if that's better. Code: [Select] if ($mail->send()) { return true; } else { $NOTICE++; $NOTICESTR[] = "We were unable to e-mail an e-mail notification <strong>".$to["email"]."</strong>.<br /><br />A system administrator was notified of this issue, but you may wish to contact this learner manually and let them know their accommodation has been removed."; application_log("error", "Unable to send accommodation notification to [".$to["email"]."] / type [".$type."]. Zend_Mail said: ".$mail->ErrorInfo); } Thanks in advance. I'll check back in a bit. Code: [Select] <html> <center> <form method="post" action=""> <b>Email</b><br><input type="text" name="email"/><br> <b>Password</b><br><input type="password" name="password"/><br> <input type="submit" name="submit" value="Login"/><br> </form> <?php if(isset($_POST['submit'])){ echo echo_post($_POST['email']); function echo_post($postvar){ return $postvar; } } ?> </center> </html> the filename is index.php How come I get the undefined function echo_post on line 14? I know it is probably something simple but I am kind of new to this, if you could help me out that would be great NB: The first section of php in this thread is extracted from the second. It is where the problem lies - ($newItem = $XMLpage->createElement('item', $updateValue);). I am trying to simply add an element into an xml document via DOMDocument.createElement(). However the following returns a fatal error: Quote <b>Fatal error</b>: Call to undefined method DOMElement::createElement() The error section in question extracted from the full function //load up and get ready the xml file to edit $xml = new DOMDocument('1.0', 'utf-8'); $xml->load($fullPathToXML); //load the page we are changing $XMLpage = $xml->getElementsByTagName('page')->item($page_number); //created the new item node $newItem = $XMLpage->createElement('item', $updateValue); //append the item to the xml sheet on the correct page $XMLpage->appendChild($newItem); //now save the xml to file $xml->save($fullPathToXML); Would anyone have any ideas why it is returning a fatal error here? I have used the official example on the DOMDocument.createElement() and the php version i am using is 5.3.8 The full function (the rest of which works fine): /*** modifying a single section of an xml sheet ***/ public function model_updateXMLfile($id = null, $updateValue = null, $inputType = null) { //if either the values sent are empty if(empty($id)) { exit(); } //get the comain name form the sessions $xmlFile= $_SESSION['xmlFile']; //replace all . with DOT as this will be the actual file name $xmalFileName = str_replace('.','DOT',$xmlFile); //get the xmla location directory from the sessions $xmlLocation = $_SESSION['xml_location']; //first make the path a whole path based the $_SESSION['xml_location'] $fullPathToXML = WEBROOT.'xml/'.$xmlLocation.'/'.$xmalFileName.'.xml'; //now get the coords of what page to change $id_exploded = explode('_',$id); //page number to edit $page_number = $id_exploded[0]; //item number $item_number = $id_exploded[1]; //load up and get ready the xml file to edit $xml = new DOMDocument('1.0', 'utf-8'); $xml->formatOutput = true; $xml->preserveWhiteSpace = false; $xml->load($fullPathToXML); //load the page we are changing $XMLpage = $xml->getElementsByTagName('page')->item($page_number); //if the user wants to change the top title if($item_number == 'topTitle') { $htmlTitle = $XMLpage->getElementsByTagName('topTitle')->item(0); $htmlTitle ->nodeValue = $updateValue; $XMLpage->replaceChild($htmlTitle, $htmlTitle); $xml->save($fullPathToXML); } //else changing an item else{ /**check the item exists, if it does then simply edit ***/ if($XMLpage->getElementsByTagName('item')->item($item_number)) { //update the content of the xml tag $xmlItem = $XMLpage->getElementsByTagName('item')->item($item_number); //change the content of the xml tag $xmlItem ->nodeValue = $updateValue; //update the node in the xml file $XMLpage->replaceChild($xmlItem, $xmlItem); //now change the attibute of the item according to what was sent $xmlItem->setAttribute('type', "$inputType"); //now save the xml to file $xml->save($fullPathToXML); } /** a new item is being created **/ else { //created the new item node $newItem = $XMLpage->createElement('item', $updateValue); //append the item to the xml sheet on the correct page $XMLpage->appendChild($newItem); //now save the xml to file $xml->save($fullPathToXML); } } //return the message saved return 'saved'; } |