php

Badword filter in PHP?

I am writing a badword filter in PHP. I have a list of badwords in an array and the method cleanse_text() is written like this: public static function cleanse_text($originalstring){ if (!self::$is_sorted) self::doSort(); return str_ireplace(self::$badwords, '****', $originalstring); } This works trivially, for exact matches, bu...

Phone number validation in PHP

I need to validate phone number in PHP. I have made following regex, but I also need to it to accept numbers starting with plus char, how can I do that? ^[0-9]$ ...

Passing values from javascript function to controller?

i m suffering with Passing values from javascript function to controller in cakephp and get using $_POST. i have tried it by different ways but didn't get success please suggest. my code is controller function index(){ $wow='rajesh'; $this->set('data',$wow); $raj=$_POST['value']; echo $raj; } javascript function che...

comparing Session value problem in php.

if ($_SESSION['user_email']!=$_SESSION['ship_user_email']) { $to= $_SESSION['ship_user_email']; mail($to,$subject,$mail_html,$headers); } there is problem in comparing values of both session. value is different but code not working. ...

Trouble editing Word document with PHP

I want to open a word document and edit it I am opening the word document from the server and at that time it's opening with garbage values (perhaps it's not being properly converted to UTF-8). When I delete those garbage values and insert something from a textarea to that file it is going to insert and from then on it opens properly. I...

how can I take starting two character of a string

how can I take starting two character of a string regardless the string lenght. ...

How do I do Textbox Submit

Hello everyone, I have a search box and a buttion. currently a user enter some text and press the search button. But I want to add another feature that instead of clicking the search button people can hit enter to search. How can I do that? Here is my code sample: <form method="post" action=""> <input id="search" name="search" ty...

Fatal error: Uncaught exception 'Exception' in PHPExcel classes

Can any one please let me know, why this following error has been thrown from PHPExcel classes Fatal error: Uncaught exception 'Exception' with message 'Could not close zip file /var/www/mydomain/myexcel.xlsx.' in /var/www/mydomain/Classes/PHPExcel/Writer /Excel2007.php:400 Stack trace: #0 /var/www/mydomain/myexcel.php(173): PHPEx...

we are getting .txt file but not getting proper alignment

we are getting the following texfile_screenshot1.JPG when we are exporting data to .txt file we need output which is shown in texfile_screenshot2.JPG following is the code $myFile = "user_password.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $newline ="\r\n"; fwrite ($fh,$newline); $stringData1 = ...

symfony: difference between doctrine model "User" and symfony "myUser"?

what is the difference between the symfony "myUser" and doctrine model "User"? where should i put the methods for an user? eg. $user->createThread(), $user->deleteThread() and so on should $user be an instance of the doctrine model User (cause i have a table called User) or the myUser that extends sfBasicSecurityUser? thanks! ...

PHP: testing two double-variables gives different result without changing the variables

Dear All, in my code i have two double values. Lets call them $a and $b. now I want to test which one of them is larger, so I wrote the following: print ($a > $b ? "larger\n" : "smaller\n"); print ($a > $b ? "larger\n" : "smaller\n"); strangely the result is larger smaller does anybody encountered a similar problem before? This pr...

Reformat a date in PHP

I have a date/time string like this: 180510_112440 in this format ddmmyy_hhmmss I need a snippet for having a string formatted like this way: 2010-05-18 11:24:40 Thanks for help. ...

how to insert PHP code snippet in javascript

my code- <?php session_start(); $_SESSION['errors']="failed"; ?> <head> function myfunc() { alert(<?php echo $_SESSION['errors']; ?>); } </head> <body onload="myfunc();"> but alert msg is not popping up. ...

Force php through the .net engine in iis7

I have converted a php to asp.net mvc and have it hosted with the Rackspace cloud. All works great apart from some php links are still linked from other sites and within search engines. My question is what do I need to add to my web.config to force php sites to go through the .net engine? These links work as expected as I can catch the ...

Getting key/value pairs from plist-style xml using simplexml in php

Here is an example bit from the xml file: <array> <dict> <key>Name</key> <string>Joe Smith</string> <key>Type</key> <string>Profile</string> <key>Role</key> <string>User</string> <key>Some Number</key> <integer>1</integer> <key>Some Boolean</key> <true/>...

jQuery Ajax form submit, to call php login script

Thanks for checking out my problem... I'm having trouble submitting a login form via Ajax for a php script to run and return a new set of html items which will be replacing the HTML in #userlinks.... heres what I have so far $("#login_form").submit(function() { return false; }); $('#login_button').click(function(event) { $form = $(...

jquery $.getJSON only works once in internet explorer

I have a php function which inserts a searchbar into each page on a website. The site checks to see if the user has javascript enabled and if they do it inserts some jquery ajax stuff to link select boxes (instead of using it's fallback onchange="form.submit()"). $.getJSON works perfectly for me in other browsers except in IE, if I do ...

tips on writing my first html embeddable widget?

i have been asked by a client to develop a javascript(mootools)/html/css/php based game as a widget which can be deployed anywhere. I have not written a widget before, so would love to get some tips and experiences so that i know some of the pitfalls before i start! Thanks :) Dan ...

Payment gateways and XSS

Hi all, I'm working on a website which takes payment from a customer. I'm using Kohana 2.3.4 and have created a library to handle the payment gateway I use (www.eway.com.au). Basically I'm just using their sample code, copied into it's own class. Anyway, the code works fine and I can make payments, etc. The issue I have is when the pay...

PHP: How do I find (Oracle) parameters in a SQL query?

Suppose you have a string: "SELECT * FROM TABLE WHERE column1 = :var1 AND column2 = :var2" Now, how do I get an array with all the variables like so: Array ( [0] => :var1 [1] => :var2 ) I've tried it with PHP's preg_match_all, but I struggle with the regex. $varcount = preg_match_all("/ :.+ /", $sql, $out); ...