php

Insert similar data into two tables

Hello all.. I have the following code I use to insert form data into a single table in my db.` function insert_interests($uid, $interests) { /* first, we'll delete any entries this user already has in the table */ purge_lookup("jss_users_interests_table", $uid); /* now create the sql insert query */ global $db; $db->query(create_chec...

What is a good way to generate short and unique file/folder names?

The criteria is basically this: folders will exist for about 24-48hrs folders names can not be readily guessable by a user (if used in a URL) folder names should be short 5-15 chars Initial thoughts: printf('%u',crc32(microtime(true))); Details: When uploading a file, I basically want to keep the unique file name as named by the u...

PHP CURL call fails to a wordpress RSS feed

Hi! I'm trying to do a CURL call to an RSS feed from a wordpress, I'm not using simplexml_load_file() because it's forbiden by php.ini to do such calls, so I'm trying to get the xml via CURL, so far it works for any URL but not for wordpress RSS feeds, even if they are on the same server. If I access the Feed URL directly on my browser...

How to call an array in a function? PHP

Global scope allows you to use a variable in a function that was defined outside the function. eg $a=1; function $test(){ echo $a; } //outputs 1 but why is it that if I define a variable with an array I cannot use it the same way? $test = array( 0=>'zero', 1=>'one', 2=>'two', 3=>'three', ); function doesntWork($something){ echo ...

Error using ssl cert with PHP

I am new to php and I am getting this error trying to load a cert jameys-macbookpro41:~ user$ php -f ~/Sites/providerService.php Warning: stream_socket_client(): Unable to set local cert chain file `cert.pem'; Check that your cafile/capath settings include details of your certificate and its issuer in /Users/jamey/Sites/providerServic...

Hosting PHP

For doing development, does it matter what OS PHP is running on? In other words would it be fine to develop a PHP application on Windows and deploy on Unix (or vice versa)? In other words, do PHP applications run identically on Windows and Unix? ...

Sort Array of MultiDiminsional Arrays on More Than One "Column" (Key) With Specified Sort Options

I'm looking to be able to sort an array of multi-dimensional arrays on more than one column. To further complicate it I'd like to be able to set specific sort options per key/column. I have what is similar the result of a DB query, but doesn't actually come from one, therefore the need to sort it in PHP rather than SQL. Array ( [0] ...

Best practice for comment voting database structure

I'm working on a PHP app that has several objects that can be commented on. Each comment can be voted on, with users being able to give it +1 or -1 (like Digg or Reddit). Right now I'm planning on having a 'votes' table that has carries user_id and their vote info, which seems to work fine. The thing is, each object has hundreds of co...

Is this the correct way to send email with PHP?

I'm a bit worried if this function sends emails that can be recognized correctly on the majority of email and webmail clients the way it should, specifically I'm most concerned about this doubts: Are the UTF-8 declarations and attachments well formed? Do I need to use quoted_printable_decode()? If yes, where? Content-Transfer-Encoding:...

Database Search Term Highlighting and Result Truncating

I am currently performing a full text search on my "pages" in a database. While users get the results they want, I am unable to provide them with relevant information as to why in the world the results that came up, came up. Specifications on what I am looking for: I have HTML Data, meaning that if you search for a term such as "test"...

PHP: Session 2-Dimensional Array - Track Viewed Products

I'm trying to create an array to display the last 5 products a customer has viewed. The array is a 2 dimensional array like below... $RView= array( array( ID => "1001", RefCode => "Ref_01", Name => "Name_01" ), ... array( ID => "1005", RefCode => "Ref_05", Name => "Name_05" ) ); The array values are retrieved from ...

PHP-Soap pass method parameters

I have relatively no experience with SOAP. Im trying to work with a webservice for a client using WSDL mode. I'm having trouble passing parameters with the method and getting them to come the parameters to show up in the request as needed. I'm using the standard php soap class. I need my SOAP request to be structured like the following:...

Is this a jQuery bug, or am I missing something?

I am using jquery-1.3.2 in an AJAX web application. I use the jQuery ajax $.post() method to submit requests to the server. On the server I am using php to build an array and then json_encode the answer. Then on the client I use the callback function of the AJAX post method to process the response. All works well until I use the $.post...

Which coding style is more common?

In no way shape or form am i advertising/promoting my programming style, but as far as 'multiple variable declarations' are concerned, which case is more acceptable professionally and commonly: case 1: private $databaseURL = "localhost" ; private $databaseUName = "root" ; private $databasePWord = "" ; private $databa...

stand alone php app

What is the best way to build a non web browser stand alone php app that works with some sort of database without requiring the user to install a database server. Or am i just asking too much? ...

Redirect Loop in CakePHP

I've got a CakePHP site that is stuck in a redirect loop. I've removed every piece of code that does a redirect & I've turned off autoRedirect on the Auth object. This occurred when I logged out of the site and has persisted even after deleting all cookies and just trying to load the homepage. The index action is in $this->Auth->allow....

Virus code injected in PHP Files

Hi I own a website running on LAMP - Linux, Apache, mySQL and PHP. In the past 2-3 weeks the PHP and jQuery files on my website have become infected from malware from a site called gumblar.cn I can't understand how does this malware get into my PHP files and how do I prevent it from happening again and again. Any ideas? Thanks Vinaya...

how to hightlight visited links with tree structure?

Hello everybody!! I have list in tree structure. Example: continent1 name country1 name city1 name continent2 name country2 name city2 name When i visit continent 1 it has to be highlighted, if country is visited country has to be highlighted similarly city Again if i visit continent 2, this time continent 2 has to be hi...

PHP - Simple way to read single record from MySQL

What's the best way with PHP to read single record from Mysql please? SELECT id FROM games I was trying to find in old questions, but had no luck Thank you ...

Html form submit - ajax generated dropdown values not sent

Hi, I have a form embedded in a html/smarty template code. Inside a form there is a dropdown box with options populated from db. If you change an option, it calls a php script via onChange event using ajax that creates/populates 2 further dropdowns. This part works fine, but if you submit the whole form (involving original dropdown and...