php

Codeigniter table Join then Display Tags Problem

I have a problem that concerns blog posts and displaying the tag words from another table. I seem to be able to pull the info out of the tables fine, however when I try to display the posts and the tags, I get one tag per post. In other words if I have 7 tags for a post, I get 7 iteration's of that post each with one tag instead of 1 po...

How to remove only entirely duplicate values from an array?

I have a website where my database is set up with different artists and song titles within the same row, where it might look this: artist: The Monkees, title: I'm A Believer artist: The Monkees, title: Daydream Believer artist: The Hollies, title: The Air That I Breathe artist: The Hollies, title: Bus Stop artist: The Beatles, title: He...

Is this overkill, or good use of CakePHP's HTML helper?

I just reformatted the default layout of my CakePHP application. I eliminated as much in-line html as possible by putting almost everything inside the html helper methods. It was fun, but I'm wondering what benefit I've gained from this exercise, if any? <?php $output = implode("\n", array( $html->docType(), $html-...

what's the purpose/point of the REAL() Datatype in mysql?

what's the purpose/point of the REAL() Datatype in mysql? You have float,double and decimal which i understand but where does the "real" datatype come into it? Any ideas? Thank you in advance ;-) is real the same as float or double? ...

Why would this SQL error with "Invalid use of group function"?

This is a simple query ran when the user presses logout from my website UPDATE `user_logins` SET `active` = 0 WHERE `user_id` = 3 AND `datetime` = MAX(`datetime`) LIMIT 1 The user_id value is binded in there with PDO. I get the following exception thrown Invalid use of group function Googling around seems to say that ...

Adding features to code bases which are in dire need of refactoring

I am developing on a system that is a bit difficult to work with. It is 99% undocumented, does not follow best practices and is fairly difficult to understand (globals galore, methods spanning 50 lines, eval abuse, etc.). Unfortunately, I am fairly new to the code base and I need to add functionality. I am sure there is code in there th...

Programatically Getting POP3 Message Unique Id and Message Size

I need to access a POP3 email account and obtain the the list of messages' unique id and its corresponding file size. I'm using CodeIgniter and have access to Zend libraries. Trying to do something similar to the LIST command. Ideas? ...

Selecting rows from a table based on results from other tables in Mysql and PDO

Hi, I'm kind of stumped. I have a table of items with fields: ID, title, created_by, group. I also have another table of groups with fields: ID, created_by, group_name and a final table of users with fields: ID, username, password etc. The idea is that only items created by the logged in user or items where the logged in user i...

PHP classes and static variables - Should I use __destruct() ?

I have a class that's similar to the following: class Person { private static $_sqlData; public function __construct($id) { if (!self::$_sqlData) { self::$_sqlData = // GET THE DB STUFF } } public function getName() { return self::$_sqlData['name']; } } This has bee...

PHP: cURL and keep track of all redirections

I'm looking to cURL a URL and keep track of each individual URL it goes through. For some reason I am unable to accomplish this without doing recursive cURL calls which is not ideal. Perhaps I am missing some easy option. Thoughts? $url = "some url with redirects"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ...

Input specific data into database using CURL

Hello, I am new to using CURL, and a novice PHP coder. I would like to take specific elements on a web page (that change via AJAX) and input them into a databse using CURL. As of now, I can write a text file of a web page using CURL, but I dont really know where to go next. Any help would really be appreciated! ...

Sorting an Array of Arrays in PHP --> Need a Good Algorithm

I have an array of 15000 elements each of which is an array of 4 elements. I want to sort by the second element of the 4. Originally I made the original array's keys the second element and then k-sorted but unfortunately, some of the second elements are duplicates and since one key can't refer to multiple elements i lost some elements in...

Close WordPress site via remote data

I have a WordPress driven website and I need to be able to close the site at a moment's notice. I need some help to work out a way to do that whereby a php script will check a remote file (xml, php, whatever) hosted on another server to check for a variable (ie. website=closed). If variable is present then close the site with a message s...

How do I access my Models in CodeIgnitor?

I'm trying to get familiar with CI and I have run into a problem while trying to implement my Model. I get the following error: A PHP Error was encountered Severity: Notice Message: Undefined property: Home::$OrderModel Filename: controllers/home.php Line Number: 12 My assumption was that I was breaking some convention with the nam...

MYSQL/PHP: newbie SQL question

Hiho! I need some help. I use this SQL to check for previous / next threads. $prev=SELECT MAX(id) as prev_thread_id FROM threads WHERE id < $threadid AND forumid = $forumid $next=SELECT MIN(id) as next_thread_id FROM threads WHERE id > $threadid AND forumid = $forumid How would I do to check if theres a previous thread and then pri...

php + mysql + html + javascript = i18n headache

This has been always a problem for me , Character problem . I always tried to solve my problem with little patches , actually this never solves my problem in reality.So I am looking for very strong solution to solve all these problems.I want to learn how big apps(facebook , google, other multi lingual ajax apps and apis) solve this probl...

Encryption method that's implemented for both php and java?

Hi, I have to pass some strings from a java servlet to a php script. What options are there for encrypting the strings? I'd need a method that is implemented for both java and php (like..a caesar cipher...). Is there any standard encryption method I should be able to get a library for both java and php? I want to encrypt the strings o...

php if iterator divisible by statement for dynamic columns

Hi, Im trying to make dynamic column list that will be 4 columns total (PHP). Im echoing an array and after every time 4 array items are echod, I would like to wrap those 4 array items in a div called "column". So basically, I thought I could do this with a self counting $i++ statement, but first off I'm having trouble starting the cou...

jQuery $.post() and full URL's

Hello, I am working on a site and have 3 different branches. Typical dev->stage->production situation. All 3 run on 3 different urls: prod: http://www.domain.com stage: http://www.domain.com/stage dev: http://www.domain.com/dev So i am trying to have universal code that runs on all 3 without any modification to file p...

implode, on key and value

hi there, currently i am doing this: $values = array( 'id' => $sel['id'], 'creator_id' => $sel['creator_id'], 'campaign_id' => $sel['campaign_id'], 'save_results' => $sel['save_results'], 'send_results_url' => $sel['send_results_url'], 'reply_txt' => $s...