I have a working sortable portlet running with php and mysql.
My problem is i cant get the delete function working with just the icon inside the portlet-header.instead the deleting covers to complete portlet class (what makes sence) however i need it only for the ui-icon-closethick
$(function() {
$(".portlet").click(function() {
va...
I'm using Doctrine for database abstraction. Now I'd like to get the auto_increment primary key from the freshly-created (and save()'d) object - but $obj->toArray() shows me that the field is empty after calling save().
Is there a flag that I'm not aware of that does this? Or do I really have to query the object from the database?
...
I'm working on modifying an existing shopping cart application so I'm fumbling through this. Using PHP 5 and mySql.
The code sends an email message to the client and to the user that shows which product they are interested in. The page is rendering the product and the attributes correctly. When the email is sent the product portion work...
Hi everyone.
I am trying to create a regular expression that understands mathematical equations (>, <, =, <=, >=, !=). Which is something pretty simple. I have come up with:
/(.*)([!<>][=]|[<>=])(.*)/
But when I use this regex in PHP, with preg_match, if equation is XYZ!=ABC, it just matches with =. Shouldn't it match the first expr...
I'm trying to validate that an uploaded file really does have the .csv extension. This code isn't working, however:
function upload_validate($form, &$form_state) {
// code that does work ...
else {
$file = file_save_upload('upload');
$errors = file_validate_extensions($file, 'csv');
if (! empty($errors)) {
form_set_err...
Until now, I've been the only person who has had access to the editing tools/forms for my sites content, so using http authentication in an SSL protected directory has worked for me.
About to add someone to the content entering team so I'm wondering what PHP libraries you'd recommend for authentication and permission/access control to t...
Question: How do I strip HTML tags but allow the greater and less-than sign using PHP?
If I used PHP's strip_tags() function, it doesn't quite work:
$string = '<p>if A > B</p>'
echo strip_tags($string); // if A B
// but I want to output "if A > B"
UPDATE
Basically, I only want to allow/display plain text.
...
I'm a PHP developer, so when I started working on a new SaaS project I naturally planned from day 1 to do it in PHP.
However, I would like to be a bit more pragmatic about this decision since it's one I may have to live with for some time if the project is successful. For that reason, why should I chose PHP as my development language...
In my validation class I have this:
$fields['a_1'] = 'First Question';
$fields['a_2'] = 'Second Question';
$fields['a_3'] = 'Third Question';
$fields['a_4'] = 'Fourth Question';
This is getting old--I have about 40 of these to write, and each set has matching validation rules:
$rules['a_1'] = 'hour';
$rules['a...
I'm wondering what is the difference between the hash extension and the mhash extension?
When should I choose one over another and why?
...
I am using strpos() to find the needle in the haystack. But, I want it to only find the needle with the same string length. E.g.:
$mystring = '123/abc';
$findme = 'abc';
$pos = strpos($mystring, $findme); // THIS IS FINE
$mystring = '123/abcdefghijk';
$findme = 'abc';
$pos = strpos($mystring, $findme); // THIS IS NOT FINE
So, I...
I have an DataMapper class which has some private and public methods. The DataMapper class itself is in the system layer because it is auto-generated code. The user (developer) uses the DataMapper class in the domain layer (or business logic layer).
There are some methods of the DataMapper which are used only by the framework, and which...
I've seen dozens of PHP snippets that go like this:
function DB_Quote($string)
{
if (get_magic_quotes_gpc() == true)
{
$string = stripslashes($string);
}
return mysql_real_escape_string($string);
}
What happens if I call DB_Quote("the (\) character is cool");? (Thanks jspcal!)
Aren't we supposed to strip slas...
The array is an instance variable of the same object. I want to keep track about what instance variable has changed it's value, so it seems to be a simple solution to pass the instance variable itself as an key to an associative array.
Is this perfectly fine with PHP or does this have some bad side effects?
...
I have a fairly massive web site for which I need to modify the names of the files shown in the URL. I am using Apache 2 with mod_rewrite enabled. I currently have the following configuration in my .htaccess file:
RewriteEngine on
RewriteBase /
RewriteRule ^CakeList\.php$ TastyThingsList.php [T=application/x-httpd-php]
Now, when I a...
How do I use the form API to make a field that only accepts names of registered users? I know how to do the autocomplete to suggest user names already.
Specifically, I'm looking to replicate the field in the normal node creation process that allows the user to specify an author.
...
Everything in my code works but $num_results...
Book-O-Rama Search Results
Book-O-Rama Search Results
//create short variable names
$searchtype=$_POST['searchtype'];
$searchterm=$_POST['searchterm'];
$searchterm=trim($searchterm);
if (!$searchtype || !$searchterm) {
echo 'You have not enter...
Consider the functions sort and array_reverse.
Why does one modify the variable passed, whereas the other return a new version?
$a = array(3, 1, 2);
sort($a);
// $a === array(1, 2, 3)
array_reverse($a);
// $a === array(1, 2, 3)
sort could just as easily been written to return a modified copy of the argument, and vice-versa for arra...
I have a function which would query database and get content if it exists for particular id and in there I have this Piece of Code:
var_dump($a); ---STEP 1
return $a ---STEP 2
var_dump($a); ---STEP 3
exit(); ---STEP 4
When I do var_dump($a), it gives me ---STEP 1
object(ArrayObject)[67]
public 'shoppingBasket' =>
...
I'm trying to retrieve products that carry same attribute. Specifically multiple select type. It seems the basic methods don't work. Selecting only the "name" attribute, I get all my products listed. When I try to filter "shop_by_color", it filters down, but not entirely. Not sure why it removes some and leaves others, even though they a...