php

MySQL choking on curly (smart) quotes

I'm inserting some data into a database from a form. I'm using addslashes to escape the text (have also tried mysql_real_escape_string with the same result). Regular quotes are escaped, but some other quotes are not. For example, the string: Homer's blood becomes the secret ingredient in Moe’s new beer. is converted to: Homer\...

killSession() PHP function inside $(window).unload

I'm doing a simple chat script and I have the killSession function which kills the current session and deletes the user from the DB. The problem is that after the name is set and verified the chat form doesn't load, it just kills the session and goes back to the loginForm(). Here's the script: <?php if (!isset($_SESSION['name'])) { log...

How do you calculate an end time based on start time and duration?

I'm building a event calendar and pass a start time to PHP, in the format of 2009-09-25 15:00:00. A duration gets passed as well, that might be in the format of 60 minutes or 3 hours. Converting from hours to minutes isn't the problem. How do you add a length of time to an established starting point to correctly format the end time? ...

Passing varible types though mod-rewrite

Hello i am having a issue with htaccess mod_rewrite, maybe someone here could point in the the right direction. my site has 1 main file [index.php] all the navigation is done by passing vars in the url string eg index.php?page=about this is working ok with my .htaccess [below] domain.com/about some of the pages have a second variabl...

PHP Web-App Design

Am looking for a guide, or simple to understand method of designing a website. I have a good idea of how to do various things in PHP anyways, basic knowledge of OOP, and functions and what not... But I need some structure, to keep me on track and let me know what I should be doing. Is there any websites, guides, or methods that can...

Getting newlines instead of slash-f-s when echoing RTF from PHP

Hi, I'm migrating a old (circa 2001) PHP 3 app to a new PHP5 server. 90% of the code worked right out of the box after migration and most of the remaining bit worked once I went through the old php.ini and changed settings in the new php.ini to match. Still there's one really annoying thing. One of the major things the app does is creat...

struggling with special characters (html_entity_decode, iconv, and more)

I've been struggling with getting a bunch of characters translated down to core utf-8 to store them in my database. PHP iconv fails on many characters, so i've been forced to build my own 'solution', which really isn't a solution if it doesn't work, and it fails almost completely in windows, so developing with iconv is mostly fruitless...

undefined $header variable in php class

Hi, I'm new to php so I'm not sure why this is throwing an error. The class I'm working with asks for the following (I assume I should enter something in the blank areas): var $headers = array( "User-Agent"=>"SkipJack 1.0", "Referer"=>"", "Host"=>"", "Acc...

K-means clustering: What's wrong? (PHP)

Hello! I was looking for a way to calculate dynamic market values in a soccer manager game. I asked this question here and got a very good answer from Alceu Costa. I tried to code this algorithm (90 elements, 5 clustes) but it doesn't work correctly: In the first iteration, a high percentage of the elements changes its cluster. From ...

Session login vs HTTP authentication. Advantages Disadvantages

I noticed a few big sites use HTTP authentication. Im wondering what the main difference is between this and session based logins are. Any advantages or disadvantages. Any explanation and or suggestions would be helpful as i'm trying to decide which login to use for my site. thanks ...

How do I export from MySQL to an Excel file in my PHP site?

I'm displaying a table of data: [Name] [Tel] [Email] [checkbox] Name 1 000 [email protected] Name 2 000 [email protected] (checked) Name 3 000 [email protected] (checked) (BUTTON TO DOWNLOAD CHECKED IN XLS) What I'm trying to achieve here is to create this button which will allow the user to download all checked entries in an XLS file? ...

PHP fsockopen Is Slow

I'm playing around with the IMAP protocol in PHP using fsockopen to send and receive commands. My preliminary experiments work but are insanely slow. It takes about 2 minutes for the simple function below to run. I've tried several different IMAP servers and have gotten the same result. Can anyone tell me why this code is so slow? <?php...

Will side-effects be executed in this if clause

Does the function add_new_user run the SQL INSERT query if it is inside the if clause? I have the functions function add_new_user ( $username, $email, $passhash_md5 ) { -- cut: database INSERT queries return 1; } I use the code abo...

How to view PHP on live site

Is it possible to view the PHP code of a live website ? ...

Zend Framework Select Objects And UNION()

I'm pretty sure this is not possible in Zend Framework (I have searched the Web, the documentation and issue tracker) but I just want to make sure so I'm asking here. $select = $this->select(); $select->union($select1, $select2); That doesn't work of course. To explain what I need. I need to use UNION() to merge 2 tables in a SELECT q...

Determine Final Destination of a Shortened URL in PHP?

Hey, How can I do this in PHP? e.g. bit.ly/f00b4r ==> http://www.google.com/search?q=cute+kittens In Java, the solution is this: You should issue a HEAD request to the url using a HttpWebRequest instance. In the returned HttpWebResponse, check the ResponseUri. Just make sure the AllowAutoRedirect is set to true on t...

How to remove a function programmatically in a WordPress RSS feed ?

I'm trying to remove the the_guid() function that appears in feed-rss2.php. I've tried remove_action('rss2_item', 'the_guid') or remove_filter but nothing happens. I’ve also tried different hooks like the_content_rss... The function appears on line 43 of feed-rss2.php, enclosed by <item></item>. Update With echo current_filter(), I fo...

What tool can I use to generate a PHP class usage report for my application?

I have a fairly large object-oriented php 5 project, and as part of a change impact analysis, I'd like to compile a report on the usage of each existing class throughout the project. It would help me immensely if I could find an existing tool that will analyze all the files in my project and generate some sort of report that lists, for...

MySQL Date Search MM/DD/YYYY to MM/DD/YYYY

I have a table in MySQL That looks like the following: date |storenum |views ------------------------------- 08/21/2009 |42 |3 ------------------------------- 08/22/2009 |43 |1 ------------------------------- 08/21/2009 |43 |4 ------------------------------- 08/22/2009 |42 |22 ------...

Understanding && in PHP if -clause

How can you get 1 as an output from #2? #1 I ran this code echo validate_email ( $email ); echo validate_password ( $password ); echo validate_username ( $username ); I get 111 which means that everything is ok. #2 I run this code function validate ( $email, $password, $username ) { if ( (validate_email ( $email ) == 1) ...