php

What is the difference (when being applied to my code) between INT(10) and INT(12)?

If I use INT(12) vs INT(10) or INT(8) what will this actually do in terms of me using in code? (This is a spin off of a previous question) I read through the manuals and I think I understand what they're saying, but I don't actually know how it would apply to my php/mysql coding. Can someone provide an example of where this would actu...

How to store a session value in the textbox when the page is loaded???

I am having a search text box. In that box, I want to store the previous search value when the page is loaded next time. For that i created session for the textbox value when the search button is clicked. But i dont know how to replace the session value in the textbox when the page is next loaded. Help me. Any help will be highly appreci...

Select Text After Pattern

I'm trying to select all text in-between following a specific pattern: Sample Text: "by thatonekid (Posted Mon Jan 12, 2009 7:17 pm) fell onto the trail right below one of the most traveled walls at the point! yikes! " Every text I work on will start with: "by USERNAME (Posted DATE) <br /> theTextIWant" I thought about exploding on...

How Do You Clean up a PHP Project?

I have been working on a small php app (400K total). But in the process of building and learning I have a lot of junk files. I didn't do my job and name them properly, ie demo1.php ect... Is there a way to do dependency checking? Or is it just delete, refresh and repeat? Then undelete when needed? ...

Database schema design: What to do about unverified invitations?

I'm not quite sure how to approach this issue: I am creating a web application that has an invite only registration system. An admin user sends an email invitation to a user, the user clicks the link, and takes them to a page where they can create an account that has been linked to their email address. My initial idea was to insert a r...

Duplicate a record in MySQL

I have a table and I want to duplicate specific rows in the table. I know this is not the best way to do things but we are looking for a quick solution. Here's something harder than I initially thought, all I need to do is copy an entire record to a new record in an auto-increment table in MySql without the need to specify each field. T...

php error reporting

Is there a common standard for reporting errors in your class functions? I've seen some c functions that you pass the error string to, so that if there is an error you can see what it is in that string, You need pointers for that though. I'm reluctant to use the return, because sometimes you do need the return for other variables. One...

Mysql GROUP BY and COUNT for multiple WHERE clauses

Simplified Table structure: CREATE TABLE IF NOT EXISTS `hpa` ( `id` bigint(15) NOT NULL auto_increment, `core` varchar(50) NOT NULL, `hostname` varchar(50) NOT NULL, `status` varchar(255) NOT NULL, `entered_date` int(11) NOT NULL, `active_date` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `hostname` (`hostname`), KEY `st...

Building conditional statement across multiple models (CakePHP 1.2.5)

Let's say I have 3 models: User, Region, Country. User belongsTo Region Region belongsTo Country Each of these models is using the Containable behavior. I'm attempting to find users from the country with code 'US'. Here's what I'm attempting: $users = $this->User->find('all', array( 'conditions' => array('Country.code' => 'US')...

How feasible is it to translate this Ruby websocket / flashsocket server into PHP?

How feasible is it to translate this Ruby websocket server to PHP? http://github.com/gimite/web-socket-ruby/blob/master/lib/web_socket.rb I know a little bit of Ruby and a decent amount of PHP, thought I've never done socket programming. I'd like to build a chat app on top of what gimite has put up on git, but all my sites are in PHP. ...

Redirecting all uri's to script possibly with htaccess

I am trying to design a small site where most of (95%) of site assets will be passed through home sort of PHP script, and the remaining 5% are being hosted from a subdomain (background images, logos, etc. What I would like is that whenever a page is called, say www.example.com/blog/My_trip_to_the_andes the page that would be called is h...

Iterate Doctrine Collection ordered by some field

I need something like this: $products = Products::getTable()->find(274); foreach ($products->Categories->orderBy('title') as $category) { echo "{$category->title}<br />"; } I know is it not possible, but... How can I do something like this without creating a Doctrine_Query? Thanks. ...

How to preserve hyperlink when submitting via php form into MySQL

Hi All, I've created a form that stores free text fields into a MySQL database. All works fine and the data is displayed back as intended when viewed. Except for one niggle. In an attempt to prevent malicious attacks I have used mysql_real_escape_string to remove any unwanted code from the input. However, I need to be able to preserv...

Initialize class property with an anonymous function

Why is not possible to initialize a property to a function when you declare the property in php? The following snippit results in a Parse error: syntax error, unexpected T_FUNCTION <?php class AssignAnonFunction { private $someFunc = function() { echo "Will Not work"; }; } ?> Yet you can initialize a property to a st...

object serialization in PHP (using __sleep)

I am having a difficult time getting object serialization to work properly. According to the documentation, I need to return an array of the variable names I want to serialize from the __sleep function. I did this, but as you can see from the first line of the output, my 50 is nowhere to be found. And when I attempt to unserialize that, ...

How to prevent cookie poisoning

I save data in a cookie to authenticate users for the next login (remember me option). This data is encrypted and hashed. But here's the problem: Anyone can take this cookie and put it on another machine and it will work. I heard that is called cookie poisoning How do I overcome this? ...

PHP/Smarty Shop Script Problem

Smarty Template and PHP.... I'm trying to get Shop-Script Free by Webasyst to display the same shopping cart on 2 different websites. I want to only use one admin section. I can get the categories, product names, product counts, prices and layout to display properly on both websites but I can't get the product images to show up on the ...

flat-file database php application

I'm creating and app that will rely on a database, and I have all intention on using a flat file db, is there any serious reasons to stay away from this? I'm using mimesis (http://mimesis.110mb.com) it's simpler than using mySQL, which I have to admit I have little experience with. I'm wondering about the security of the db. but the fil...

Select and group rows in summary by hour

I have a table containing view/click records. The time is stored in a unix timestamp and I need to be able to pull out all of them within the specific month/day (based off of timestamps), but more importantly and the part I don't know how to do is group them by hour. I need to be able to do this in a single query rather than looping thr...

Why must I assign the result of PHP's end() array function to a variable to operate on the result?

I've tried to delete the possibly empty last entry of an array as follows but I get the error: "Can't use function return value in write context": if (empty(end($crontabEntryList))) { array_pop($crontabEntryList); } If I first assign end's return value to a variable (as at the bottom) I am able to delete that last entry if emp...