I have an HTML form as follows: I want that the user of this form enters data in the input box. Then I would like this data to be the value of a PHP string – e.g. $username = “MY_NAME”; where MY_NAME is the value of the HTML form entered by the user. If the input by the user in
Tag: php
Select entries between dates in doctrine 2
I will go insane with this minimal error that I’m not getting fix. I want to select entries between two days, the examples below ilustrate all my fails: opt 1. $qb->where(‘e.fecha > ‘ . $…
Magento 1 – Where does Magento Set a Quote Item’s Price?
Whenever you load the cart page in Magento, the following code is run $cart->init(); $cart->save(); One side effect of this is that the prices for any items in the cart are updated if the …
If PHP’s mt_rand() uses a faster algorithm than rand(), why not just change rand() to use the newer implementation?
The purpose of a random number function is to get — you guessed it — a random number, something you cannot predict (or be very hard to predict with certainty). If the mt_rand() function is faster …
Get comments in a PHP file
I’ve been trying to get the comments out of a certain .php file on my server, in order to parse its variables. I thought Ii found an easy way to do this, however, the function I use doesn’t return anything, even though I clearly have comments in the file. Here are the comments I use: Here’s …
How to use the Google calendar API’s functions
I’m trying to use the Google calendar API and I can’t properly call the built-in functions. For reference: This code return a fatal error: Call to a member function getItems() on a non-object I don’t understand how to use an object which is not instantiated by a New(). Answer You need to add…
Rotate an array with weekday names as keys to start with tomorrow
I have the following array: I’d like to rotate the elements of this array with the first key being the tomorrow. Let’s say today was Wednesday, I’d want my array to look like this: I already have the weekday available (e.g. a string ‘thursday’). It gets passed into the function t…
Get category tree recursively (Yii)
I have a table with following structure: categories id name parent_id I want to get the tree of categories with single function. I’ve written something like this in my model, but it doesn’t work. Can someone help me with this? Thanks. Answer I’ve finally solved the issue. If someone interest…
Parse error: Syntax error, unexpected end of file in my PHP code
I got an error: With this code: What’s the problem? Answer You should avoid this (at the end of your code): and this: You shouldn’t put brackets directly close to the open/close php tag, but separate it with a space: also avoid <? and use <?php
How can I get parameters from a URL string?
I have an HTML form field $_POST[“url”], having some URL strings as the value. Example values are: https://example.com/test/1234?email=xyz@test.com https://example.com/test/1234?basic=2&email=xyz2@test.com https://example.com/test/1234?email=xyz3@test.com https://example.com/test/1234?email=xy…