php

containable on hasMany relationship

Greetings, I am trying to tear down query returned from find call using containable in CakePHP. for example I have 2 models, User and Post. User hasMany Post. Now when I am using containable on find call like so: $User->id = 1; $User->find('first', array( 'fields' => array('id'), 'contain' => array('Post') )) It will not re...

PHP - Replacing ereg with preg

Hi, I'm trying to remove some deprecated code from a site. Can anyone tell me the preg equivalent of ereg_replace("<b>","<strong>",$content); Thanks. ...

Hello Word example in MVC approach to PHP

Can anyone provide a very simple example of Hello Word in MVC approach to PHP? ...

APNs notification failure...

Hi , i tried the following code (PHP) $apnsHost = 'gateway.sandbox.push.apple.com'; $apnsPort = 2195; $apnsCert = 'apple_push_notification_production.pem'; $streamContext = stream_context_create(); stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert); $apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apn...

Make MySQL table unique

Hay, I created a spider to crawl through a PDF document and log every word in the document into a table in a MySQL database. Obviously words like 'the', 'and', 'or' etc appear in a book many, many times. I'm just wondering what's the quickest method to remove dupe values from a table? ...

passing special charactor

Hai I want to download a PDF file containing a special character @ But it got an error , how I passé a special character like © etc ,, I am using PHP with OOPs Concept. Please help me .. Thanks in advance ...

What are the pros and cons of writing a Facebook application in .NET?

I am beginning to write a Facebook application. I have read many articles about the subject and have learned that Facebook has an official PHP API, and .NET has a Facebook toolkit from Codeplex. Both options have many references and resources, but it seems that Facebook itself was written in PHP, not .NET. So does PHP or .NET have bett...

Remove control characters from php String

Hi all, seems trivial but give me a hard time: Does anyone have a hint for me on how to remove control characters like STX from a php string. I played around with preg_replace("/[^a-zA-Z0-9 .\-_;!:?äÄöÖüÜß<>='\"]/","",$pString) but found that it removed way to much. Is there a way to remove only controll chars? tia K ...

Print the value in loop in Jquery ready function

Hey all, somehow still not able to do what I’m inted to do. It gives me the last value in loop on click not sure why. Here I want the value which is been clicked. Here is my code: $(document).ready(function() { var link = $('a[id]').size(); //alert(link); var i=1; while (i<=link) { $('#payment_'+i).click(function(){ //...

Sending email attachments with php outlook adding extra attachments with random names

<?php // array with filenames to be sent as attachment $files = array("sendFiles.php"); // email fields: to, from, subject, and so on $to = "[email protected]"; $from = "[email protected]"; $subject ="My subject"; $message = "A logo has been sen't by". $_SESSION['loggedin_business_nam...

Validating multidimensional arrays in Code Igniter with form_validation library

I'm having a weird problem with the form_validation module of code igniter. I'm trying to validate multi dimensional arrays from the form post, but its not working as expected. I've used this a hundred times (exaggeration) with standard form posts so I'm familiar with it. My form post looks like this Array ( [location_edit_id] =>...

Listening a socket on client machine using Javascript

Is that possible? I'm writing a web-admin interface for a network-system. I need to listen to a specific UDP port and show it in browser. Can I do that in javascript? Also; any other ideas are welcomed. early-edit: Here's another idea: I have php and perl support at server-side. JS can call a php script to start listening, which will a...

how to: add keyboard scroll / enter to autosuggest script?

I created an autosuggest script using php, ajax and some css but I can't figure out how to make it so when the script suggests results to allow the user to scroll down the list of results using keyboard arrows and then press enter to select desired result. The script currently displays in a list format and and onclick the results the in...

PHP Sockets - Not Reading Output

Hi all, I'm having some problems reading from a socket. Basically, I can connect to the machine without an error. I can write to the machine without an error. I cannot seem to read the output. Here is what I'm doing: $header1 = chr(0xFF).chr(0xFB).chr(0x1F).chr(0xFF).chr(0xFB).chr(0x20).chr(0xFF).chr(0xFB).chr(0x18).chr(0xFF).chr(0xFB)...

Special access to enclosing object?

Is there a way, in PHP5.3, for an object $enclosed to know which object $enclosing that it is inside of? Essentially I want to make some variables of $enclosing be accessible only to $enclosed without specifically passing those vars in. class Enclosing { private $enclosed;//Enclosed object private $othervar; function __construct(...

$ajax->link() doesn't work in Firefox?

I am reading Beginning CakePHP, and to make it so that you can vote on comments, it tells you to create a couple of AJAX links: <?=$ajax->link('<li>up</li>', '/comments/vote/up/'.$comment['Comment']['id'], array('update' => 'vote_'.$comment['Comment']['id']), null, false)...

Separating SQL, PHP and the view when listing categories and products in Kohana

I want to migrate to Kohana with my small websites and I'm trying to separate the SQL, PHP and the view, but I've some problems with this one. I have to tables. Every category can have multiple products. Categories table id category Products table id category_id product This was my previous code (converted to Kohana's query bui...

Mod_rewrite and $_GET variables

If I am mod_rewriting a URL from: http://www.mysite.com/blog/this-is-my-title/1/ to http://www.mysite.com/blog.php?title=this-is-my-title&amp;id=1 ...is it possible then to arbitrarily attach a get value on to the URL later, or does the mod_rewrite throw it off? MY REWRITE RULE: RewriteRule ^blog/([A-Za-z]+)/(0-9]+)/? blog?ti...

How to do command line from PHP script

I need to write a script that will give users info on a given Unix account (the same Unix server that the script lives on). Mostly thing kinds of things that are in the passwd file or available via finger. PHP is in safe-mode, so I can't access the passwd file via something built into php like file_get_contents(). Also, because it's in ...

How to get a rough estimate of LAMP application capacity?

I have a LAMP application running fine, however the number of users are increasing each day. I don't want to be hit with a surprise one morning and find that everything broke because of overload. Is there a way to get a rough estimate of what capacity of the LAMP it is at? I know that a full detailed report is many books worth of study...