php,variables,opencartRelated issues-Collection of common programming errors
hippietrail
php eol
When is it a good idea to use PHP_EOL? I sometimes see this in code samples of PHP. Does this handle DOS/Mac/Unix endline issues? Most of the PHP I write is for generating HTML, and I use <br/> instead of actual newlines, so haven’t used this constant before.
Steve
php html
I have strange problem. I am showing these links to interact with them via jQuery and at the very end it always puts symbol “1” for some reason. I’ve looked through all my pages and this was the one that caused it. Can you please explain why and how can I avoid that? It does not matter what I select from cat, 0 or any other viable id… P.S. I know that code is not complete, but this is just draft to make it all work together…<?php$sql = “SELECT * FROM cat WHERE catSubID = 0”;$result = mysq
the_void
php wordpress shortcode
I just found out that both ‘echo’ and ‘return’ works fine for displaying content from a shortcode function. function foobar_shortcode($atts) {echo “Foo Bar”; //this works fine }function foobar_shortcode($atts) {return “Foo Bar”; //so does this }I just want to know, is there any difference between using either of these? If so what’s the recommended one? I normally use echo in this case; is it okay?
user2315306
php button delete
I manage to succesfully read and display data from my database with the following code: http://pastebin.com/rjZfBWZX I also generate a delete button for each row of the table 🙂 Clicking the delete button calls “obrisi.php” which is supposed to delete that row but i messed something up :S Here’s obrisi.php code: http://pastebin.com/mrFy1i7SIm getting a Parse error: syntax error, unexpected ‘FROM’ (T_STRING) :S
OMG Ponies
php mysql
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING is the message. It came up from this line of code:$query = (“SELECT * FROM users WHERE user_name = $_POST[‘user_name’] & password = $_POST[‘password’] & user_type = $_POST[‘user_type’]”);Does anyone out there know the meaning of all this? If so, does anyone know how to deal with this?
hakre
php pcntl
Can anybody tell me why using the pcntl lib on production servers is discouraged? The PHP manual tells very briefly about it, and I’m in a dire need to use this library… Is there another way to do the same thing in php?
markus
php
In a legacy php script I found the following line of code:$CacheLite =& ( “string” );Which provokes an error:Parse error: syntax error, unexpected'(‘, expecting T_NEW or T_STRING orT_VARIABLE or ‘$’Is it a mistake or a way of passing by reference or something else I don’t know. Do I have to enable/disable something in my php configuration in order for this to work?
Ami
php
I’m using PHP 5.3.5 with Fast-CGI.When I try to use gmdate() to set the initial value for a parameter, I get the following error:Parse error: syntax error, unexpected ‘(‘, expecting ‘)’ inMyClass.php on line 3Here’s my code (line 3 is the line where myFunction is declared):function myFunction($myDate = gmdate(‘Y-m-d’)) {// … }Am I doing something wrong? Is this a bug? This also occurs if I do the same thing in a class function.
bee.catt
php function
$myVar=myFunction(array_reverse(explode(‘.’, $_SERVER[‘SERVER_NAME’])));Anything wrong with nesting functions like this?
F. Orvalho
php mysql
Is it possible to re-write the code below, maybe even with an if (result > 0) statement, in just one line (or simply shorter)?// a simple query that ALWAYS gets ONE table row as result $query = $this->db->query(“SELECT id FROM mytable WHERE this = that;”); $result = $query->fetch_object(); $id = $result->id;I’ve seen awesome, extremely reduced constructs like Ternary Operators (here and here – btw see the comments for even more reduced lines) putting 4-5 lines in one, so mayb
gkiko
c file parsing variables
I use stat system call on Linux and retrieve file information.char *parent_dir; // for example: /run/atd.pid/ struct stat buf; stat(parent_dir, &buf);buf structure type:struct stat {dev_t st_dev; /* ID of device containing file */ino_t st_ino; /* inode number */mode_t st_mode; /* protection */nlink_t st_nlink; /* number of hard links */uid_t st_uid; /* user ID of owner */gid_t st_gid; /* group ID of owner */dev_t st_rdev; /* device ID (if spec
marcog
php class variables php4
I have a class likeclass blah extends blahblah{private $variable = ‘5’;function somefunction(){echo $variable;} }this works in php 5, but not in php 4. I get a error:Parse error: parse error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VA….I also tried with public and static. Same error.How can I add a variable inside that class that I can access from all class functions?
Óscar López
variables scheme racket mutable
I am new to racket and have run into an instance where I need a mutable numeric variable Below is a function that works thru a string of bits (101011….) and if it encounters a 1 alters a numeric variable named “value” and if it encounters a 0 has to alter that same variable “value”. So when we get to the end of a string we should end up with a total for “value”. (define (implode bstr value)(for ([c (string-length bstr)])(display (string-ref bstr c))(if (eqv? (string-ref bstr c) #\1) (displayl
Lior
python variables pointers
Variables in python are just pointers, as far as I know. Based on this rule, I can assume that the result for this code snippet:i=5 j=i j=3 print iwould be 3. But I got an unexpected result for me, it was 5.Moreover, my python book does cover this example:i=[1,2,3] j=i i[0]=5 print jthe result would be [5,2,3].What am I understanding wrong?
yusufiqbalpk
php function variables global
Need some code examples on how to affect a variable outside of a function without using globals. Also I want to know where should I use global and where not.Thanks in advance.
Shivasubramanian A
java variables
Was there any reason why the designers of Java felt that local variables should not be given a default value? Seriously, if instance variables can be given a default value, then why can’t we do the same for local variables?And it also leads to problems as explained in this comment to a blog post…
hakre
James
jquery variables
This code doesn’t work:var number = $(this).find(‘.number’).text(); var current = 600; if (current > number){// do something }HTML:<div class=”number”>400</div>Seems there is some problem with converting text() from text-like value to number.What is the solution?
user1090427
python variables maya
I’m writing a script for maya, it’s in python, but this should relate to most things.If I run my script on the left side of a setup the values for translation etc will be something like 29.292 or 68.215.The problem is that the right side is a mirror, so it’s -29.292 or -68.215.I need to check if the symbol ‘-‘ exists within the variable and if so remove it.How do I do this?Thank you
delaccount992
php variables echo php-5.3 heredoc
When I try to do this:var $example = “Example”; echo <<<EOT <p>$example</p> EOT;I get this error:Parse error: syntax error, unexpectedT_VAR in ….. on line …What is going on here?? To my knowledge this should work.I’m using PHP 5.3.5.
Robert Green
php wordpress opencart vqmod
After installing vqmod I am getting the following error when I try to access the homepage of my site.Parse error: syntax error, unexpected ‘elseif’ (T_ELSEIF) in [ROOT]/vqmod/vqcache/vq2-system_library_cart.php on line 146
nachito
php .htaccess seo opencart
How can you customize system URLs in OpenCart? For example, I would like http://example.com/index.php?route=checkout/cart to be displayed as http://example.com/cartI know OpenCart provides SEO URLs for products, categories, manufacturers and information pages, but it doesn’t look like there is anything built-in (at least prior to version 1.5.0) for anything else.
Rachel Gallen
php opencart
I am using a linux(dailyrazor) server and when i uploaded the php files, it throws an error like “500 Internal Server Error The request was not completed. The server met an unexpected condition.” but when i am uploaded html files it works fine. The error message changes to 403 Forbidden Access is forbidden to the requested page:Can you suggest where the problem is?
Xonnie316
javascript error-handling opencart payment-gateway
One of my Opencart stores seems keeps showing up an error during the last step before a customer is about to do a purchase.I’m getting a “SyntaxError: Unexpected token <” error message during the Payment Method checkout.Here’s the link to the test site: http://www.shaunmeilak.com/shibcadesign21-2/It would be a massive favour to find out exactly whats the issue.
user2580953
opencart
have done manual installation of opencart in hostfree server but when i start doing a demo checkout ,while clicking on viewcart it show “SyntaxError: Unexpected token< ok {“country_id”:”222″,”name”………… on message box. i think it has to be loaded in the substate box below country. the same proble i have seen in the admin section while editing store location.Please help i am new in opencart. also installed vqmod .https://lh5.googleusercontent.com/-D2PCJ_C_WGw/UhisF6SZCNI/AAAAAAAAAZA/-hj
Marcel Gwerder
syntax-error opencart
When I add items to an order in backend I got an error like this:I have tried to upload the original files and that didn’t help! I’m using one.com to host it and I have had several error before this one!
PieterB
ajax opencart
I’m using OpenCart 1.5.1.3 and having this strange error on Guest Shipping in Ajax. I’m getting the error “Unexpected token <“. I have tried everyting, change the Ajax code, look at the controller, but no luck. You can try it yourself at http://www.biancabonte.nl/shop/. Put something in the cart and checkout Direct instead of registering. Then the problem occurs. Thanks
pb2q
internet-explorer crash seo opencart keyword
I have an issue in OpenCart. When the SEO Keyword is filled for a product, it works fine on Firefox and Chrome but on IE (ver 6.) it crashes. Error:The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.eBio link Any idea what could be the issue?
Cris
javascript jquery opencart
I have an opencart shop. Locally, uploading images work without a glitch. Online, it works only if the image is very small. If I upload an image of, say 300kb, the loading gif next to upload keeps spinning and I get the errors:ajaxupload.js:Line 609: if (response) { Line 610: response = eval(“(” + response + “)”); Line 611: } else { Line 612: response = {}; Line 613: }Why is this happening?EDIT: I did console.log(response) and you were right, what came back was the HTML of the 404 page. Bu
kalingga
javascript json opencart
I would like to show the geozone in the registration account step as dropdown menu, just like the zone (region). But the value of the geozone is dependent to what customer choose in the zone (region).The PictureIn the process, I already did some modifications to the controller, view, including controller. Just like in the pic below :The geozone field is Kotamadya/Kabupaten. But when I choose the region Aceh, the geozone field is not refreshed.Error MessageI got error message like below :SyntaxEr
Web site is in building