php,magento,pdo,magento-1.7Related issues-Collection of common programming errors
Mohammad
php netbeans character-encoding whitespace file-encodings
I’m editing the functions.php file of a WordPress theme and whenever I edit it, even when the edit is adding a single space the server returns error:Parse error: syntax error, unexpected ‘}’ in /theme/functions.php on line 1 This is where I add the single space:<?php load_theme_textdomain(‘theme’, get_template_directory() . ‘/languages’); <- I added a single space hereand everything dies after that. This is not a consistent error, as it goes away after I replace the whole functions.p
netcoder
php unit-testing sockets
Greetings Stackoverflowers,I have an application in which a communication abstraction layer exists. Each implementation in this layer, called a connector, provides my application with a way of exchanging data with a connected peer (e.g.: through HTTP, TCP sockets, UDP sockets, etc.).Per example, I have a Connector_Tcp class that implements methods such as read, write, open and close.I need to write a unit test for that class. I know that unit tests should have as less dependencies as possible. U
Taffman
php tags fgets
I’m using fgets to read a text file that contains field names delimited with the “<” and “>” characters. It seems like fgets is seeing these field names as tags and stripping them. I thought that only fgetss stripped tags and that fgets should allow this. I’m testing this with the following code:<?php $handle = @fopen(“Test.txt”, “r”); if ($handle) {while (($buffer = fgets($handle, 4096)) !== false) {echo $buffer;}if (!feof($handle)) {echo “Error: unexpected fgets() fail\n”;}fclose($handle
Chris
php
I’m not sure how simple is this to solve, but I assume I’m doing something wrong. I’m new to PHP, so bear with me, please.When I started learning PHP, I always placed all my project files into the same folder along with index.php and thus included everything like this:<?php include(‘./translation.php’); ?>Later on in the process of learning as I gained experience and my skill increased, I had to start using folders and place my files into sub folders. I ended up successfully including my f
DarkCthulhu
php string utf-8 comparison
I’m trying to compare two string lets say Émilie and Zoey. Well ‘E’ comes before ‘Z’ but on the ASCII chart Z comes before É so a normal if ( str1 > str2 ) Won’t work. I tried with if (strcmp(str1,str2) > 0) still don’t work. So i’m looking into a native way to compare string with UTF-8 characters.
meder
php javascript html validation dom
I’m looking for something like http://validator.nu/, I’ll be validating html input ( string ) and I want to notify the user if there are any missing end tags, whether a certain element can’t have a certain attribute, things of that nature ( HTML 4.01 Strict validation basically ).Sidenote: I won’t be dealing with XML/DTDs, and I don’t want to correct the user input like how http://htmlpurifier.org/ does it.
PeeHaa
php
I have a bit of a general dissatisfaction about the way passing by reference works in PHP, coming from a Java background myself. This might have been talked about before on SO, so I’m sorry if this might seem redundant.I’m going to give a code example to make things clear. Say we have a Person class:<?phpclass Person {private $name;public function __construct($name){$this->name = $name;}public function setName($name){$this->name = $name;}public function getName(){return $this->name;
user1615069
php logging
Well…I do know it’s good to log errors when the website is in production and error reporting is off. But what should I actually log? I can’t log all errors, so I should to choose some most errors-probable places in the code and call the function with some message to log this. Should I use try-catch to do this? And is it actually the best way to do this?
NullPoi?te?
php mysql
PHP variable not working in sql query..Am just a begginer in php. pls tell where am going wrong.thanks in advances.$sql = ‘SELECT email_id FROM dealer WHERE dealerid=”‘mysql_real_escape_string($id).'”‘;$rt = mysql_query($sql); $row = mysql_fetch_row($rt);if($row) {echo “<h1>Number:</h1>” . $row[0];while($row = mysql_fetch_assoc($rt)) {var_dump($row);} }
Galen
php validation date datetime language-agnostic
I’m working on date validation for a validation library. A date format and a variable containing the date to validate will be supplied to the library.$validator->validate( $_POST[‘date’], ‘m/d/y’ );It’s pretty easy to do basic validation with DateTime::createFromFormat()if ( DateTime::createFromFormat( $format, $date ) !== false ) {// “valid” date }My issue is that with this method invalid dates such as 23/23/23 pass because the DateTime class will shift the date and set it to 2024-11-23. I
Drew Hunter
ajax magento magento-1.4
I’m writing a Magento Admin extension that has some ajax callbacks in it. Up until now I’ve been echoing the json I’m feeding back through the ajax call with a simple echo statement in the controller. It “works” but I get a bunch of errors like this in my log file: 2010-12-14T15:37:05+00:00 DEBUG (7): HEADERS ALREADY SENT: [0] /home/simplifiedsafety/www/store/app/code/core/Mage/Core/Controller/Response/Http.php:44 [1] /home/simplifiedsafety/www/store/lib/Zend/Controller/Response/Abstract.php:7
rxt
php magento magento-1.4
I have a local magento installation to test out new extensions and configurations. Now I try to open the Connect Manager locally, but get a blank screen, and the following errors:PHP Warning: Unexpected character in input: ‘\x16’ (ASCII=22) state=0 in /var/www-vhosts/magento.local/htdocs/app/code/local/Aitoc/Aitsys/Model/Module/License/Light/Performer/Reader.php(36) : eval()’d code(18) : eval()’d code(1395) : eval()’d code on line 1 PHP Parse error: syntax error, unexpected T_STRING in /var/w
Marcin Orlowski
php magento magmi
I am using the Column Mapper to map columns from my source file to the respective system columns.I get an error when the source column header has a “(” or “)” in there. The error occurs within the magmi UI. Here is an example:Mapped columns list: Name,Syle#,Width (inches) New name for col Name: name New name for col Style#: sku New name for col Width (inches): widthUpon saving the profile, I get the following error:**Warning:** syntax error, unexpected ‘(‘ in ColumnMappingItemProcessor.conf on
viakondratiuk
bash magento automation
I am interested in automation of Magento installation. I found one nice article with steps, how to achieve this. I downloaded their script and run it from cli:./mage-install.sh localhost root test “abcABC123” “1.7.0.2”And get such error:./mage-install.sh: 21: ./mage-install.sh: Syntax error: “(” unexpected (expecting “}”)I am not familiar with bash, here is a part of code, which is responsible for it:compareVersions () {typeset IFS=’.’typeset -a v1=( $1 )typeset -a v2=( $2 )typeset n difff
teresko
php magento
Does anyone know how I can get a list of products belonging to a specific category from within a view file in Magento?
svick
c# .net soap magento wsdl
Before today my Magento soap worked fine, i could do a logon and a session string would be returned. I have tried the same thing today and it did not work. version 1.4.2.0I have tried to connect to 2 different Domains, with each set up with magento and i get the same error. Can anyone tell me why that would be?this is the error i am getting. {“Possible SOAP version mismatch: Envelope namespace http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting http://schemas.xmlsoap.org/soap/envelope/.”}
user3179784
php jquery html css magento
I am trying to put a jquery dropdown for “My Account” in the header after you login (try username test and password test@123) but I keep getting this error:Uncaught TypeError: Cannot call method ‘dropit’ of nullI even moved:<script type=”text/javascript”>jQuery.noConflict();jQuery(document).ready(function () { $(‘#myaccountmenu’).dropit(); }); </script>to the bottom before the footer, to no avail. Any ideas?
Abhijit Navale
html magento caching block
My magento homepage contents are displayed more than one time. I expect them to appear only once per page. I tried to put this code to \app\code\core\Mage\Catalog\Block\Product\List.php file as a solution:protected function _construct(){$this->addData(array(‘cache_lifetime’ => 900,’cache_tags’ => array(Mage_Catalog_Model_Product::CACHE_TAG),’cache_key’ => $this->getCacheKey()));} public function getCacheKey(){return $this->getRequest()->getRequestUri().$
Diego
magento block
I found an unexpected issue while attempting to load a block within a magento module. The block name was *Mycompany_CustomerModule_Block_CustomerModuleDashboardDataBlock* (yes, the name is very long, but I added the module name all blocks related to the module to avoid confusing a dashboard.html with the one used by Magento Core). The issue is that, if I try to load such block, with the following command:$this->getLayout()->createBlock(‘customermodule/customermoduledashboarddatablock’)Mage
Knowledge Craving
php magento store product
I have two websites for specific Store Views – English & German. Normally, I could have maintained 1 Website with two different Store Views, but it was the specific requirement of my client, to have each website for each specific store view.Problem is I am not able to update / create different product names / descriptions, each for a product website, programmatically. I’m using this code to do it, which I found to be the same for different price:-$combinationWebsiteWithName = array(‘1’ =>
Rob Allen
php oop design-patterns pdo
I have an app under development which uses a database for a subset of its functionality. During development we have a higher than normal expectation that the database won’t be available. Once launched, we would still like the main body of the application to work even if there is a database outage. All of my database-facing classes extend a base class which grants them database access, however in the concrete classes there are some methods which perform selects directly (meaning not through the
Ricki
php mysql pdo count
I have a PHP script which allows voting based on a login system. I am trying to switch all the code to PDO instead of MySQL. I’m having trouble switching this particular piece of code. Here is the original:$get_votes = mysql_query(“SELECT * FROM votes WHERE poll_id = 1 “); //select all votes to this poll$votes = array(); //the array that will be containing all votes$total_votes = 0;while($vote = mysql_fetch_assoc($get_votes)) { //retrieve them $answer_id = $vote[‘answer_id’]; $votes[$answer_id]
JoeyD473
php mysql zend-framework pdo zend-db
I am using Zend Framework and am trying to connect to a database by it’s IP address.. I keep getting the following errorFatal error: Uncaught exception ‘Zend_Config_Exception’ with message’syntax error, unexpected ‘=’ inC:\xampp\htdocs\App\application/configs/application.ini on line27 ‘ in C:\xampp\php\zf\library\Zend\Config\Ini.php:182 (I removed thefull stack trace)I traced the error to the application.iniresources.db.adapter = PDO_MYSQL resources.db.params.host = 192.168.1.34 resources.db.pa
grab
php if-statement pdo statement
How to put PDO bindParam in if statement? i tried to do a different variations, bu not one of them worked.function get_all_pages($subject_id, $public = true){$db = new PDO(‘mysql:host=localhost;dbname=name;charset=utf8’, ‘root’, ‘whatewer’);$query = “SELECT * “;$query.= “FROM pages “;$query.= “WHERE subject_id =:id “;if ($public){$query.= ” AND visible =:visible “;}$query.= “ORDER BY position ASC”;$query.= “ORDER BY position ASC”;$stmt = $db->prepare($query);if ($public){$stmt->bindParam(‘
Duncan
php arrays pdo
Using the guidelines suggested by netnuts for the use of Data Objects for Database access, specifically in relation to unnamed placeholders# the data we want to insert $data = array(‘Cathy’, ‘9 Dark and Twisty Road’, ‘Cardiff’); $STH = $DBH->(“INSERT INTO folks (name, addr, city) values (?, ?, ?); $STH->execute($data);unfortunately seems to produce a parse error for the code# the data we want to insert $data = array($first_name, $second_name, $email_from, $telephone, $dateofbirth, $address
maxgee
php function if-statement pdo statement
I am writing a if statement that if the two dates listed are equal it echo’s the first date and if the they aren’t(else statement) it echoes “date1-date2” I have it inside a function and I do not know if I am alowed to do that.Here is the error I am getting Parse error: syntax error, unexpected T_IFHere is my function:function getfevent ($conn) { $sql = “SELECT `name` FROM `event` WHERE `featured` = 0 LIMIT 0, 30 “; $statement=$conn->prepare($sql); $statement->execute(); while($row=$st
Yusaf Khaliq
php mysql pdo
As I was advised I have changed from mySQL to PDO calls yet I can’t seem to get past accessing the actual database as below $db = new PDO(“mysql:host=localhost;dbname=info;charset=UTF-8”, ‘admin’, ‘xxxxxx’);as it returns Parse error: syntax error, unexpected T_VARIABLE in db.php on line 8I have checked through forums and from what I’ve read the server does support PDO , furthermore phpinfo() is disabled for security reasons so I can’t turn to that, Have i actualy made an error in the string or d
SiKni8
php sql pdo
<?php $dbhost=”host”; $dbusername=”user”; $dbpassword=”pass”; $dbname=”db”;try {# MySQL with PDO_MYSQL$DBH = new PDO(“mysql:host=$dbhost;dbname=$dbname”, $dbusername, $dbpassword);echo “Connected Successfully”; } catch(PDOException $e) {echo $e->getMessage(); }# close the connection $DBH = null; ?>When running it in my server, i get the following error:Parse error: parse error, unexpected ‘{‘ in /home/web/i/htdocs/search/pdo.php on line 7I am trying to do a test to use PDO to save v
php beginner
pdo
<?php $config[‘db’] = array ( ‘host’ => ‘localhost’ ‘username’ => ‘root’ ‘password’ => ” ‘dbname’ => ‘phplogin’ );$db = new PDO(“mysql:host={$config[‘db’][‘host’]};dbname={$config[‘db’][‘dbname’]}”,$config[‘db’][‘username’], $config[‘db’][‘password’]);?>receives error: “Parse error: syntax error, unexpected ”username” (T_CONSTANT_ENCAPSED_STRING), expecting ‘)’ in C:\webroot\wamp\www\index.php on li
blue thief
php mysql class pdo const
I am defining constants in a classclass config {const DB_PDO_Connect = “‘mysql:host=localhost;dbname=XdbX’,’XuserX’,’XpwX'”; }In another class I try to create a new PDO objectclass user {function login() {$db = new PDO(config::DB_PDO_Connect);After that line, $db is not an object so something is not working, but if I replace it with;class user {function login() {$db = new PDO(‘mysql:host=localhost;dbname=XdbX’,’XuserX’,’XpwX’);(copy and paste the string from the config class) it works.I can echo
user2168570
magento-1.7
I am using cart_product.remove api to remove products from the customers cart. The Api works fine and removes the product from cart. But it does not update the cart total after removing the product from cart. How do I update the cart total?Thanks
Abhijeet kumar sharma
magento cron crontab magento-1.7
I am working on a custom Magento module and set up a Cron job for it. Every thing is working fine but i am worried about the unexpected behavior of Cron job ( Random number of execution ). When i execute cron.php manually it calls the observer’s method of my module more then 1 times (Number of execution is not fixed, some times 3 some time 5 etc). I just want to execute observer’s method only once. Here is my code.1) Daffodil/Birthdaywish/etc/config.xml ……<crontab><jobs><daff
Shadowbob
magento magento-1.7
I have a Module that loads a whole bunch of Observers for a specific task on one theme. I’ve setup a mobile theme that doesn’t need this specific module. How do I disable the module for that theme ? I read the answers on Magento, how to disable module programmatically? that isn’t really helpful for my case because I don’t have any controllers in the module.I am checking the Package name if (Mage::getSingleton(‘core/design_package’)->getPackageName() == ‘package’) return true; but this doesn’t
alberto2000
html css magento themes magento-1.7
I cannot seem to find up to date tutorials for creating own themes from scratch for the current release of Magento, can anyone point me to one? The most comprehensive I know which but is a little out of date is thisOr could anyone give me a short step by step crash course on building one? I have some knowledge about the theme system of Magento by now.
Greg Demetrick
php xml magento google-chrome magento-1.7
I am working on a relatively extensive but not huge XML file that is being delivered from a custom Module in Magento using a controller. Everything has been going well and I have been able to get it to work and add nodes with no issues. The browser (Chrome in this case) has been rendering the XML document fine and stylizing it as expected. In order to display the XML headers properly via Magento I am using the following code:/* Set display to render output as an XML document */ $this->loadLay
Nathan Bunney
php magento pdo magento-1.7
I am having a problem similar to The PDO extension is required for this adapter but the extension is not loaded but not the same.The Magento install is running fine but when I try to run:require_once(APATH.MAGEPATH.’/app/Mage.php’); umask(0); Mage::app();in a directory outside of Magento I get the error:Fatal error: Uncaught exception ‘Zend_Db_Adapter_Exception’ with message ‘The PDO extension is required for this adapter but the extension is not loaded’ in /home/inzana/public_html/Store/lib/Zen
Noho Adam
mysql pdo cron magento-1.7 cron-task
until last week magento cron was working fine. Suddenly it started giving following error. I have checked my local.xml and database username, password and all these things are there. My site is working fine. The error only happen in cron. Cron is working fine.. I am getting email from cron with the following error. When i run cron.php in browser two times it starts and executes jobs. Please help how to resolve this issue to run cron properly.X-Powered-By: PHP/5.2.17 Content-type: text/htmlFatal
Th3Cuber
php magento-1.7
My Magento site is very slow (taking min 20-30 sec for home page loading). Right now there are no products, only site under the construction. We have only 200 categories/sub categories, maximum.I have hosted my site on a dedicated server.I have optimized basic page speed properties through the magento admin panel.When i try to check the error log in SSH, it shows me the below error message.#2 {main}thrown in /home/domainname/public_html/lib/Varien/File/Transfer/Adapter/Http.php on line 96 [09-Ju
j0k
jquery html slider magento-1.7 zurb-foundation
I’m trying to load a slider called flexslider but its not working and i can’t figure it out.It has something to do with a line in magento local.xml: <!– Add js/css globally –> <reference name=”head”>Any help please? http://flexslider.woothemes.com/The console shows this error “Uncaught TypeError: Cannot call method ‘flexslider’ of null” The specific section is this one:<div class=”std”><script type=”text/javascript”> $(window).load(function() { $(‘.flexslider’).flexslid
Andrew Taswin
javascript html magento-1.7 zurb-foundation orbit
I tried to integrate the foundation inside magento here while I stuck on initializing the javascript. I used the normal initialization from the website, in which results with:Uncaught TypeError: Object # has no method ‘foundation’Therefore i tried to look around and found another way to initialize it using jQuery(document).ready(function(){jQuery(document).foundation(function (response) {console.log(response.errors);}); });Which remove the error from the console, but didnt actually initiate the
Web site is in building