php,sql,magento-1.6Related issues-Collection of common programming errors
flem
php javascript jquery
I have a couple form elements that when clicked update the database and disappear.At first, I have a button that reads Check In. Upon clicking it, the database is updated and a dropdown is presented in place of the button. In the dropdown, there are locations for the user to choose, that have values of their corresponding location-number, which upon clicking update the database. The last option is labeled Check Out, and upon clicking it, the database is supposed to be updated one last time, and
Fabien
php scope callback
class myClass {$myVariable = ‘myCallback’;function myFunction() {$body = false;$callback = $this->myVariable;function test($handle, $line) {global $body, $callback;if ($body) {call_user_func($callback, $line);}if ($line === “\r\n”) {$body = true;}return strlen($line);}…curl_setopt($ch, CURLOPT_WRITEFUNCTION, ‘test’);…} }function myCallback($data) {print $data; }$myCls = new myClass(); $myCls->myFunction();Warning: call_user_func() [function.call-user-func]: First argument is expected t
RaphaelDDL
php jquery ajax json-encode parse-error
I’m using PHP’s json_encode() to return some data, retrieved by jQuery’s ajax():Simplified JS:$.ajax({dataType: ‘json’,contentType: ‘application/json’,cache: false,type: ‘POST’,url: ‘./api/_imgdown.php’,error: function(jqXHR, textStatus, errorThrow) {console.log(jqXHR, textStatus, errorThrow);},success: function(data, textStatus, jqXHR) {console.log(data, textStatus, jqXHR);} });The PHP is:header(‘Content-Type: application/json; charset=UTF-8’); //default apiResponse $apiResponse = [“status” =&g
RSM
php if-statement
I have an input text area which when filled out and sent, puts whatever was typed in into the variable$inputThis is then put through an if statement to check whether or not its the letter a. If it is then echo – you wrote the letter a, else – you did not write the letter a. <?php $input = $_POST[“textarea”];echo $input;echo “<br />”;if($input = “a”){echo “You wrote a”;}else{echo “You did not write a”;}?>It does work, but in the wrong way. Every letter I type in comes as ‘You wrote
Thew
php api imgur
i have a question about the imgur api. I want to create a gallery for my website using the imgur api, but how can i create a file uploader that uploads to the imgur servers?Here is what i created:<?php include ‘xmlparser.php’; // From http://www.criticaldevelopment.net/xml/doc.php if($_SERVER[‘REQUEST_METHOD’] == “POST”){$data = file_get_contents($_FILES[“file”][‘tmp_name’]);// $data is file data$pvars = array(‘image’ => base64_encode($data), ‘key’ => HERE_MY_API_KEY);$timeout = 30;$
PeeHaa
php
For example is there a difference between the two? Is one preferred to the other?Class Node{ public $parent = null;public $right = null;public $left = null; function __construct($data){$this->data = $data; } }Class Node{ function __construct($data){$this->data = $data; $this->parent = null; $this->left = null; $this->right = null; } }
T9b
php mysql validation escaping sanitization
I’m just discovering PHPs sanitize and Validate filters, and I had been using MySQL’s mysql_escape_string to stop SQL Injection.Now I discover that PHP can also help and I guess logically these procedures are not exclusive in their function: ie you can sanitize and validate in PHP and still arrive at a situation where escaping is necessary.Am I right or am I overlooking something?
Chris Allington
php mysql
I have created a real estate website and I wanted to have the listings sorted by the last update and completeness of the listing. So I have been trying to figure out how to sort by a field in mysql (completion_score) in combination with the most recently updated listing. The completion score would be on a 100 point scale with 0 being bad and 100 being perfectly complete. I will have the completion score calculated when the listing is added and updated and saved in the mysql database. I am guessi
j0k
php forms symfony2
I have an entity type form field in my Symfony2 project. $builder = $this->createFormBuilder(); $projects = $this->getProjects();$builder->add(‘project’, ‘entity’,array(‘class’ => ‘OpexMarketOPEXMOPEXBundle:Project’,’required’ => false,’choices’ => $projects,));The problem I’m having is, when the getProjects() method will return an empty result set, the drop down list will have all the projects in the Project table.Is there any way to disable this behavior?
Clement Herreman
php symfony1 doctrine persistence many-to-many
Today I met some unexpected behavior on doctrine (1.2). SituationI’ve a Document class, and an Anomaly class. A Document can have many Anomalies, and an Anomaly can be found on many Documents.#schema.ymlDocument:columns:id: { type: integer(12), primary: true, autoincrement: true }scan_id: { type: integer(10), notnull: true }name: { type: string(100), notnull: true }Anomaly:columns:id: { type: integer(5), primary: true, autoincrement: true }label: { type: string(200) }value: { ty
Jack Mszczynski
java mysql sql postgresql jdbc
I am wondering what are the differences and when to use: – Statement, – PreparedStatement, – CallableStatement in JDBC. Can You give me best practice and typical scenario of using each of these?Also – how can I enable and use caching in JDBC?
Peter Kofler
sql postgresql join hsqldb
Dear SQL gurus 😉 I have the following query (inherited from legacy) similar toSELECT bla FROM table WHERE some.id IN ( SELECT id FROM (SELECT some FROM tag WHERE blaUNION SELECT some FROM dossierinfo WHERE bla ORDER BY tag LIMIT :limit OFFSET :offset) AS aggregatedWHERE dossier_type = ‘auto’) )The full SQL is at the bottom. The problem is that is executes fine in PostgreSQL 8.2.x. For testing I added an embedded HSQL 1.8.x db, but then the query fails with07 Sep 2010 13:55:11.914 [WARN] [mai
newbie
sql sql-server tsql sql-server-2008
I had to write a query to update all records in a table based on records that exist in two other different tables. I wrote the following three iterations of the query, I think the third one is the most efficient and the first one the worst. I just wanted a second opinion, and find out if i can do better than the third version below:P.S : The first one is not really a valid SQL query, but a pseudocode of how i planned to query the database.SELECT AccountID,Label FROM QueueTableFor each record in
OracleUser
sql oracle plsql oracle10g procedure
st :=’SELECT USERNAME FROM LOGIN WHERE USERNAME =: a and PASSWORD =: b’; execute immediate st into un using username,pw;OrSELECT USERNAME INTO un FROM LOGIN WHERE USERNAME = username and PASSWORD = pw;where username, un and pw are varchar2(50) variables
Gill Bates
python sql django orm bulk
Business: I encountered a problem – when operating with large datasets with Django ORM, canonical way is manipulate with every single element. But of course this way is very inefficient. So I decided to use raw SQL.Substance: I have a basic code which forms SQL query, which updates rows of table, and commiting it:from myapp import Model from django.db import connection, transaction COUNT = Model.objects.count() MYDATA = produce_some_differentiated_data() #Creating individual value for each row c
Justin Cave
sql plsql insert hierarchy
I have a table that stores trees. There is a node_id and parent_id. When I try the following:insert into table1 select * from table2 start with node_id = 1 connect by prior node_id = parent_id order by parent_id nulls firstI get this error:Error starting at line 6 in command: insert into table1 select * from table2 start with node_id = 1 connect by prior node_id = parent_id order by parent_id nulls first Error report: SQL Error: ORA-02291: integrity constraint (XVTEST.REGIONAL_DEFAULT_DELETE) vi
HLGEM
.net sql
I’ve been tasked to write a small app to be used by a single user. This app will pull in ~500 employee names/departments from our master employee DB. Then the user will enter like 5 fields for each employee. Those 5 fields will typically only change once a year, but could be once a month worst case. I only am supposed to keep track of 2 years worth at any given time. I’ve looked at SQLite and SQL CE and I’m just not thrilled by either of them. SQL CE doesn’t want to allow the data file to reside
marc_s
sql sql-server
My problem is that I can’t remove instance. Here is an example right now I have two instances SQLEXPRESS SQLEXPRESS2012I have SQL Server 2012, in order to remove instance I go to Control Panel -> Add and remove programs -> choose Microsoft Sql Server and after that I will get to UI where I can do different manipulations with different stuff. In this UI I am able to delete SQLEXPRESS2012 but I can’t select SQLEXPRESS. Also when I am in SQL Server Management Studio I can connect to SQLEXPRE
Erwin Brandstetter
sql arrays postgresql postgresql-9.2 window-functions
I’m attempting to query a table which contains a character varying[] column of years, and return those years as a string of comma-delimited year ranges. The year ranges would be determined by sequential years present within the array, and years/year ranges which are not sequential should be separated be commas.The reason the data-type is character varying[] rather than integer[] is because a few of the values contain ALL instead of a list of years. We can omit these results.So far I’ve had littl
Sandeepan Nath
sql mysql case switch like-operator
I have this Tags tableCREATE TABLE IF NOT EXISTS `Tags` (`id_tag` int(10) unsigned NOT NULL auto_increment,`tag` varchar(255) default NULL,PRIMARY KEY (`id_tag`),UNIQUE KEY `tag` (`tag`),KEY `id_tag` (`id_tag`),KEY `tag_2` (`tag`),KEY `tag_3` (`tag`),KEY `tag_4` (`tag`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2937 ;INSERT INTO `Tags` (`id_tag`, `tag`) VALUES(1816, ‘(class’),(2642, ‘class\r\n\r\nâ?¬35’),(1906, ‘class\r\nif’),(1398, ‘class’),(2436, ‘class)’),(1973,
Pascut
magento email zend-framework smtp magento-1.6
I have a magento website. I want to send mails using SMTP. I’ve found the below script hereI created this file: app/code/local/Mage/Core/Model/Email/Template.php in order to overwrite the original core file.The problem is that I receive this error: Parse error: syntax error, unexpected T_VARIABLE in /home/xxx/public_html/app/code/local/Mage/Core/Model/Email/Template.php on line 103public function getMail() {if (is_null($this->_mail)) { $my_smtp_host = Mage::getStoreConfig(‘system/smt
Bartosz Górski
php magento authentication apache2 magento-1.6
I’ve set up a new server for my magentocommerce.Unfortunatly when I moved the domain to the new location (tests have been done using another domain) a weird issue started happening: when the login page displays on the frontend, or the backend and I (and customers, of course) do submit the right credentials the page refresh, the cookie gets set but the form is displayed again. It’s such a cache being served instead of the right content (catalog).The only solution actually is delete the cache on t
abnab
php api magento soap magento-1.6
I am using SOAP V2 to create a cart and add products to it. I am having issues adding product to the cart. Below is my code and the error I am getting. It says “One item of products do not have identifier or sku”<? /*** Example of order creation* Preconditionsare as follows:* 1. Create a customer* 2. ?reate a simple product */$user = ‘users’; $password = ‘password’;$proxy = new SoapClient(‘http://handyimports.com.au/index.php/api/v2_soap?wsdl=1’);$sessionId = $proxy->login($user, $password
Theodores
php javascript mysql magento magento-1.6
I’ve moved a magento install from the current shared hosting to a new VPS. I also moved it on a staging server.It works very well on the staging server but it doesn’t on the VPS.The issue I get (when trying to add a product) is:Uncaught ReferenceError: productAddToCartForm is not defined I moved the DB and the full source base, on both systems… so I can’t really figure out why it’s not working on the production VPS.By googling it seems that often it was a conflict between jQuery and Prototype
Ronny
php magento fatal-error magento-1.6
i am trying to clone my webshop again for a test environment. (magento 1.6.2 on a dedicated server)I never had any trouble doing this. I just deleted all the old content in FTP and DB and then i make a copy of the live store and synchronize the db.Then i change the url in the db and the test-db in the local.xml.I also clean the var/cache and var/session.This always worked well.But yesterday did the same … but now i get a http 500 error. (white screen)From the error logs: “GET / HTTP/1.1” 500 2
Carsten Gehling
magento magento-1.6 magento-admin
I am trying to make a Magento module, to enable our Magento-webshop customers to import all our products automatically. Since I’m not yet very proficient in Magento development, I run into a few stops on the way… :-)Right now I try to make a AdminController in which the index page should simply display a text and a button to start the import process. It’s the “addButton” part, that I have trouble with:public function indexAction() {$this->loadLayout();$block = $this->getLayout()->crea
chanz
magento magento-1.6 magento-1.7
Bundle product is not visible at the front end maybe due to js issue, after upgrading from 1.6 to 1.7.0.1debugging with firebug i found the following js error<script type=”text/javascript”> var optionsPrice = new Product.OptionsPrice( Fatal error: Call to undefined method Mage_Bundle_Model_Product_Price::getBasePrice() in /var/www/vhosts/stage.planetjill.com/httpdocs/app/code/core/Mage/Bundle/Model/Product/Price.php on line 117 </script>the method in price.phppublic function getFinal
user1744827
magento magento-1.6 configurable-product
thanks in advance to any help that anyone is able to offer. When a custom option field in magento is set to ‘required’ it does not add to cart and asks user to select option. However when I uncheck the required option in admin in then works. I think this issue maybe affecting config products so I would like to find a solution other than not use the required option.Using Magento 1.6Thank you
hims056
magento-1.7 magento-1.6 magento-admin
every thing has been working well on my localhost but when i have uploaded it in the server after that whenever i am trying to login my admin panel then it is giving the following error.Fatal error: Call to undefined function curl_setopt() in D:\INETPUB\VHOSTS\lostandfound.co.in\nityapusta\magento\jewellery\lib\Varien\Http\Adapter\Curl.php on line 87
The Smart Dude
php sql magento-1.6
Help. I have been struggling with this error for a few days now and have yet to find an answer. I am trying to add a few columns to the orders grid in Magento 1.6.2 I followed the instructions from: [http://www.milessebesta.com/web-design/magento-customize-backend-order-grid-to-have-sku-e-mail-address-and-phone-number/][1] Here is the error message: SQLSTATE[42S22]: Column not found: 1054 Unknown column’main_table.sfo.customer_email’ in ‘where clause’Here is my code:protected function _getColle
Web site is in building