php

Sanitization of User-Supplied Regular Expressions in PHP

I want to create a website where users can test regular expressions (there are many out there already...such as this one: http://www.pagecolumn.com/tool/pregtest.htm). Basically, the user provides a regular expression and some sample text, and the results of the regex evaluation will be spit back. I want to evaluate the regex on the ser...

Why imagettftext does not work?

I have problems with the "imagettftext" function. The following code works if I comment the problematic line (I see a yellow rectangle). session_start(); $text = $_SESSION['code']; header("Content-type: image/gif"); $image = imagecreate(150, 15); $red_bg = 255; $green_bg = 255; $blue_bg = 155; $bg_col = imagecolorallocate($image, $red_b...

How to declare abstract method in non-abstract class in PHP?

class absclass { abstract public function fuc(); } reports: PHP Fatal error: Class absclass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (absclass::fuc) I want to know what it means by implement the remaining methods,how? ...

getting the POST request from web server

Hi I'm having troubles debugging a POST request I'm making from my web server to another web server. I'm trying to communicate with a SOAP web service but from some reason a code that worked well from local machine fails when executing on my server Looking for a way to see the post request my server make to the web service server web ser...

handling single and double quotes while fetching and printing in the page

sorry ma question went wrong a bit the alis has value like alias ="Sri Kumaran Children's Home - CBSENothing is as pure and divine as knowledge." but as the url i have given . when i hover over the link it just shows alias=Sri Kumaran Children . how to solve this problem $myresult .= "<a href='Schools/{$alias}'><img src='/school/school...

member variable and member function have the same name

class test { public $isNew; public function isNew(){} } $ins = new test(); $ins->isNew Here,how does php parse $ins->isNew? ...

php, second last comma in a string to break string, or regex

I'm trying to find a way to break a string at the second last comma, for example: piece 1, piece 2, piece 3, piece 4, piece 5, piece 6, piece 7 should be 2 parts: piece 1, piece 2, piece 3, piece 4, piece 5 and piece 6, piece 7 and piece 1, piece 2, piece 3, piece 4, piece 5 should be: piece 1, piece 2, piece 3 and piece 4, piec...

javascript too much recursion?

Hi, I'm trying to make a script that automatically starts uploading after the data has been enter in the database(I need the autoId that the database makes to upload the file). When I run the javascript the scripts runs the php file but it fails calling the other php to upload the file. too much recursion setTimeout(testIfToegevoegd()...

coding inspiration needed - keywords contained within string

Hi all I have a particular problem and need to know the best way to go about solving it. I have a php string that can contain a number of keywords (tags actually). For example:- "seo, adwords, google" or "web development, community building, web design" I want to create a pool of keywords that are related, so all seo, online marke...

Can I "Mock" time in PHPUnit?

... not knowing if 'mock' is the right word. Anyway, I have an inherited code-base that I'm trying to write some tests for that are time-based. Trying not to be too vague, the code is related to looking at the history of an item and determining if that item has now based a time threshold. At some point I also need to test adding someth...

salt and hash generation question

Hi, I would just like your feedback on something. Basically I have a value called $uniqueID which is = ID + First Letter of First Name + First Letter of Last Name + The String "CAN" I have then turned $uniqueID into a salt value as followed $salt = sha1($uniqueID); I have then turned the user's password into a hash value using md5(...

as3: using an object to pass arguments in any order - class configuration

I want to pass through configuration arguments to a class. These are all the optional vars that go into configuring the class - and should be able to run in any order. at the moment i just pass through the optional vars the regular way. Supposing the constuctor was like the following: private var _reqVar:String; private var _optVar1:St...

mysql_fetch_assoc error, can't seem to figure out what the problem is

I keep getting this error here: Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\ReadNotes\viewyournote.php on line 40 With this code here: <?php //Starting session session_start(); //Includes mass includes containing all the files needed to execute the full script //Also shows home...

CAn't resize image with GDlib2

I'm trying to resize an image of more than 3000px in width, it uploads fine if i do not resize it, but as soon as I resize the image it does not want to upload and resize, this is funny and I can't seem to understnd, since if the width of the image is alot smaller everthing works just fine. Are there limitations to this? ...

PHP in HTML <Script>

I was viewing a Appcelerator Titanium Video Tutorial and I saw they used syntax like <script type="text/php"> ... global $window, $document; mysql_connect(...) or die $window->alert('...'); $document.getElementById('xxx'); ... </script> so I have a few questions. Is it any difference if I use <?php ?> without setting $window and $do...

Javascript injection

I need to solve a problem with javascript injection in a form textarea and fields script type='text/javascript' window.location='http:site.com'; /script or a href='javascript:...' or form action... or input name... but i preserve some html tags for example a, b, ul... is this possible? ...

Week number and Week day

I have week number of current year and week day generated by date() like this. $week_number = date('W'); $week_day = date('w'); I need to format this. How can I get starting date of this week? Or day of month with $week_number and $week_day? ...

How can I read excel data (office 2007 xlsx) in PHP?

How can I read excel data (office 2007 xlsx) in PHP? Is there any library for this? ...

Get current PHP executable from within script?

I want to run a PHP cli program from within PHP cli. On some machines where this will run, both php4 and php5 are installed. If I run the outer program as php5 outer.php I want the inner script to be run with the same php version. In Perl, I would use $^X to get the perl executable. It appears there's no such variable in PHP? Rig...

Getting form data and sending it to a new tab in the browser

Hi am creating a small form where you can place postcodes to get directions, it then sends this data with the URL of Google maps with the postcode in it to show the directions. I was wondering is it possible to somehow get thenew URL i have into a new browser tab / window. The idea is that the user input the postcodes and then presses ...