php

How to pass id value with jquery to PHP?

Hello, I am trying to pass an id value to a php script with jquery. So, I was trying to create a link: <a href="#" id="superman">Superman</a> and when this link is clicked, I would like jquery to grab the id value and place it in the php script or php grabs the id? im not sure the best way. I want the id value so it can be placed in...

Why can't I select the desired node using this PHP Xpath expression ?

Using PHP, SimpleXML and the xpath() function, I want to select a child node, starting from a certain point. Can you please help me? I know in this specific case I could use an expression starting with "//", but I want to learn the right way of selecting a child node. Thanks. First try -- fails with Undefined offset: 0 error $navXmlOb...

How to implement flyweight pattern in php?

This is its definition: Use sharing to support large numbers of fine-grained objects efficiently. But I can't figure out what it means exactly. Can you elaborate with a tiny demo? ...

Is there any PHP Object Oriented Programming in Practice Tutorial?

Hi there I've learning PHP for a while, and also have read some OOP tutorials. I tried to start my own website using OOP PHP but I got quite lost. I am not sure what to do in real project. I think maybe I need some practice tutorials, which is talking about real projects. I tried to read some code of PHP framework like CodeIgniter, bu...

Trouble with jQuery form submit

I am at a loss here with some simple jQuery. I have the following code in a separate file: $(document).ready(function(){ //$("#trackit").click(function() { $.ajax({ type: "POST", url: 'include/trackit.php', data: "trackingNum=123456", success: function(data) { alert(data); } })...

Need some idea on how to store items from page2.php to the cart table?

That's the code below, It will get the ids variable from the url coming from page1.php, http://www.stores.com/cart.php?action=add_item&amp;ids=1&amp;qty=1&amp;register=0&amp;id=4 then it will either add, update or remove the item you can see the ids in each of the cases along witht he qty and id variable as well found int he url as be...

How to detect a user's language through their IP Address.

I have developed a website www.tenxian.com. It has three language versions, English, Japanese and Chinese. How can I write an effective PHP program which can automatically choose a language version based on the IP address of the visitor? If I use "if-else", the code would be much complicated; If I use switch-case, how to write it sin...

How do you sort (alphabetically by keys) a $_POST request in PHP.

I'm looking at http://www.php.net/manual/en/array.sorting.php as a reference. I'm trying to sort the $_POST by the keys. This is what I am trying, but it only prints "1". What else needs to happen, or what is missing? Thank. <?php $data = krsort($_POST); print_r( $data ); ?> ...

What does this PHP syntax mean: $var1->$var2

New to PHP. Can someone please explain this syntax. $var1->$var2 //note the second $ Thanks ...

Getting a PHP PDO connection from a mysql_connect()?

I have a legacy PHP/MySQL app that calls mysql_connect(). Tons of existing downstream code makes mysql_query() calls, either directly or through wrappers, using this connection. For new code that I develop on the app, I would like to start using PDO. If I make a PDO connection using the same host/user/pass/dbname credentials, might I b...

How to get the language value from $_SERVER['HTTP_ACCEPT_LANGUAGE'] using PHP?

<?php $language=$_SERVER['HTTP_ACCEPT_LANGUAGE']; echo $language; ?> When I use Firefox to test this block of code, I get en-us,en;q=0.7,ja;q=0.3 ; When I use IE to test the block of code, I get zh-cn . Is the value of $_SERVER['HTTP_ACCEPT_LANGUAGE'] a string? How to determine whether the preferred language is Ch...

php session vs mysql speed

i am working a on a permission system. In each page it will need to check whether if the user has the permission to do so. I have two choices, store the data in a session variable (which is only updated during login) or query the database for the information every time. Which is faster? I realized that if the permission changes, I will...

Dynamically creating zip with php

Hi, What is the easiest way of creating dynamically zip files with php? For example, I have these files on the server, Root -> Folder 1 -> file1.wav Root -> Folder 2 -> file2.jpg I want to create a zip file contains these 2 files and allow user to download it. any help ? Thx in advance ...

weird php file upload problem

Hi, i am having strange issues regarding file upload on my windows system. I am using windows 7 with iis7 on the server. i am trying on a client comp with local ip 10.47.47.13 and the server is 10.47.47.1. I have a very simple form which i couldnt make it work in some cases. the page stays on the wwwroot. ( http://10.47.47.1/3.php) 3.ph...

resize image with php

hi every one I have script to resize image. It work well except output. In out put it gives binary stream but i want image . my code is following class SimpleImage { var $image; var $image_type; function load($filename) { $image_info = getimagesize($filename); $this->image_type = $image_info[2]; if( $th...

PHP files are downloaded by browser instead of processed by local dev server (MAMP)

Everything was going great until I added AddHandler application/x-httpd-php5s .php to the .htaccess file in my local server's document root (which I change frequently depending on the site I'm working with). Since I did that when I visit http://localhost:8888 my browser just downloads the index.php and it's not processed at all, just the...

Yii Framework/PDO getting error CDbCommand failed to execute the SQL statement: SQLSTATE[42000]

I'm trying to insert some data into a table using the Yii Framework together with the PDO object and get the following error I'm building the query using this code $connection = CActiveRecord::getDbConnection(); $sql="INSERT INTO sms_logs (to, from, message,error_code,date_send) VALUES (:to,:from,:message,:error_code,:date_sen...

How to automatically parse an RSS feed for storage in MySQL database?

I need to somehow automatically update/parse a couple of RSS feeds and place them into a MySQL database almost as soon as the feed is updated, or as close as possible. However, I can't work out the best way to do this automatically - I've found tutorials for doing it when a user runs a script - but in this case it all needs to be done in...

Is there a way to extract a dict in Python into the local namespace?

PHP has a function called extract() which takes an associative array as the argument and creates local variables out of the keys whose values are assigned to the key's values. Is there a way to do this in Python? A quick google search didn't immediately show me how. I suspect there's a way with exec() but it'd be nice if there were some ...

Is it just me...or is "Facebook Mobile Web" only for PHP?

http://wiki.developers.facebook.com/index.php/Mobile I use Django/Python as my mobile website. Am I missing something? ...