php

PHP MYSQL update with hash variables.

I need some help understanding the correct way to mix variables with strings like this. I have tried every configuration I can think of and I keep getting an error. <?php include('connect.php'); foreach($_GET['item'] as $key=>$value) { mysql_query("UPDATE userprojectlist SET category_display_order = '$key' WHERE category_id = '$valu...

Reading JSON arrays with jQuery/JS

Alright, this pretty much goes along with my previous question. I'm still trying to figure out how to display data from an array which is created by a PHP file- using JS/jQuery. I'm working on a points system for ZetaBoards, and I've currently got it set up here. (Points will be displayed below the users post count once I get this workin...

php login user logic

hey all, so i've scrapped all the crappy tutorials that have never worked for one reason or another, and decided to roll out my own registration/login feature on my own, and to my surprise it actually works! But what i don't get is how the logic behind keeping somebody logged in works! Like, once they've logged in, do i just $_POST the...

PHP Unset + Undefined Offset

I'm having a little trouble with losing my array order after using unset(). Here's the code first: $id = $_GET['id']; for($i = 0; $i < count($my_array); $i++) { if($my_array[$i] == $id) { unset($my_array[$i]); } } Assume that $my_array has 4 items and $my_array[1] is equal to $id. After I unset that I try to run a ...

what is crossdomain cookies? are they really useful ? if so when is it used

What is a crossdomain cookie ? what are they meant for ? Can you give some senarios where crossdomain cookies are useful. Would appreciate for in depth explanation. ...

PHP calculate person's current age

I have birth dates on my site in format 12.01.1980. $person_date (string) = Day.Month.Year Want to add an oldness of the person. Like "Currently 30 years" (2010 - 1980 = 30 years). But makin the function just on years can't give the perfect result: If person birth date is 12.12.1980 and current date is 01.01.2010 the person doesn't ...

what is the use of go-pear.php ? What it does actually ?

Can anybody tell me why do we need to install a set of classes using a script ? PHP PEAR Lib is essentially a set of classes, is it fairly good to just copy in the hosting server. So is go-pear.bat go-pear.php is necessary or its an optional. If it is necessary would like to know why? ...

Coverting DOC to PDF programmatically

I'm looking for a library to help me convert DOC files to PDF using PHP. I'm also open to using an external website if this functionality already exists elsewhere, as long as this website has a programmatic API and is free. Any suggestions how to approach this? ...

PHP get the letter

Variable $name (string) gives something like (possible values): "Elton John" "2012" " George Bush" " Julia" "Marry III Great" Want to catch the first letter of $name and add it to $letter variable. It's important how many words (divided with spaces " ") the string has: If there is just one word, set $letter to the first letter of t...

MySQL and PHP communication problem in Mac OS X 10.6.3

I followed this instruction but not worked for me. I just wanna install and config cakephp in my new MacBook Pro and that's why I'm tried to rename my php.ini.default to php.ini. Before that, I had no problem in communicating between my MySQL and Mac pre-installed PHP. What's wrong with that instruction. ( specially "Getting MySQL and ...

PHP GD imagecreatefromjpeg cant handle big size image?

Hi. Im using WAMP5. my project is when im uploading an image automatically my program will create the thumb size.My program work normally if the size of picture about 1024x768 But when i'm uploading image with size 1576x2379 showing error like this: Allowed memory size of 8388608 bytes exhausted (tried to allocate 1576 bytes) I'm usin...

AJAX long polling, increasing efficiency

For a while I've been playing with the idea of long polling for my notification system, but i've never been able to think of a way to make it more efficient for my backend. Most implementations I have seen hold the connection open, and the php queries the database server every few seconds to see if new data has been aded. This strikes ...

PHP if else statements

We have variable $country, it can give ~50 different values. And variable $id. What we should do is to give a value for $id corresponding to $country value, like: if ($country = 'USA') { $id = 'usa_type'; } else if ($country = 'France') { $id = 'france_type'; } else if ($country = 'German') { $id = 'german_type'; } else if ($country =...

PHP filter POST from PayPal IPN?

I have a PayPal IPN PHP file set up which assigns all of the IPN post contents variables to variables. This file is only 'hit' from paypal.com (ie nobody should know it's url). My question is should I take the necessary steps to filter and sanitize the POST data from PayPal or is masking my IPN file name (IPN_082j3f08jasdf.php) enough? ...

PHP: Ignoring errors and notices in a specific class

My site is completely custom, as such I like to know when I have poorly written code. I use set_exception_handler and set_error_handler to use custom classes to log errors to a file. This includes notices and warnings. Within my own code, this is fine as I get very few logs and those that I do get are things I actually want to fix. How...

Convert numeric to letter

Hello, I'm programming an invoice script. I'm looking for a php script that convert number to letter. Exemple, the invoice show this value : 155€ The script put automatically: ONE HUNDRED FIFTY FIVE Any ideas ? N.B: I find some script but i want one that support FRENCH letters. Thank you :) ...

2 decimal numbers in php ?

For example: (a)123 / (b)1000 = (c)0,123 echo c must be 0,12 How can this be done ? ...

how to communicate HTTP authentication with jquery to authenticate login system?

I am trying to bring up the HTTP authentication box for handling my login. However, I want to communicate to my database through Ajax. But I dont know how to connect the HTTP authentication box with AJAX. Any Idea, how to do this? Please also include example ...

How to include HTMLPurifier on every page?

Okay right now I have too include the code below on every single page and every time I have too change the following piece of code every time I place it in a new web page. Is there a way I can include all this code one time and have it affect every web page and have the code work like it should? Here is the piece of code I have to chang...

Get the size of an image file

Images and script hosted on the same account (one site). We know direct link to each image: $image = "http://site.com/images/full-1091.jpg" How can we get the size of this file? Like: { do something with $image and get $image_size } echo $image_size; Its better to format $image_size like "156,8 Kbytes" or "20,1 Mbytes". Thanks. ...