php

Cookies are not working on a php session file:

I tried the following: Basically, it should say: If there's no cookie, get lang from web browser (this part works and that's the job of lang.php). If there is cookie, the session will take its value from the cookie. If there's nothing, leave it as English. session.php: /* Class constructor */ function Session(){ $this->time = t...

Struggling with number regex match

Hi, I'm trying to match only numbers and spaces in my php regex but the following fails and I can't seem to understand why, can anyone shed some light on what I'm doing wrong please? $pattern = '/^[0-9\ ]$/'; Thanks ...

overwriting column with fputcsv

I want to parse, process and then overwrite only 1 specific column in a csv file, I'm fine with the first two steps but am having issues with the third. Here's what I have so far: <?php $fh = fopen("data.csv", "r"); $row = 1; while (($data = fgetcsv($fh, 1024, ",")) !== FALSE) { $get = $data[2]; $uc = ucwords(strtoupper($get)); echo $uc...

trying to validate user input in php

I'm trying to validate user input in php. This code will check if the values are null or not. If it is null, this will require the user to input the values that are null. When all the text boxes in the html form that came before this. This code will show the submit button, and that submit button will save the inputted data into the mysql...

How to encompass the first letter in every word with HTML tags?

How to encompass the first letter in every word with HTML tags? For example: $string = replace_first_word("some simple text",'<big>{L}</big>'); echo $string; //returns: <big>s</big>ome <big>s</big>imple <big>t</big>ext edit: ohhh, forgot to mention one important point, it Needs to work with UTF-8 Unicode... because I'm planning to su...

PHP: uniqueidentifier

I ‘concat’ an id of just loaded image into mysql user record like this. Userid … Photos_ids 12 1 2 5 7 And this photo_id should be unique. (To create unique file name). Now I get a current last id from memcache. But it's not really safely, as far as I understand. It there any other ideas? (I do not add any other records int...

PHP Extension Not working

I am using WampServer 2.0 on Php 5.3.0 When I check the extensions, php_mssql is Checked. I also checked the php.ini file to make sure it is not commented out. I have my file dbase.php saved in C:\wamp\www\php. I have tried stopping the service, closing everything, and running it again. I know the problem is that the extension file is ...

ftp_connect returns NULL in PHP

I'm trying to use ftp_connect('ftp.is.co.za') [for example] in PHP 5 or higher (multiple different versions on different machines). I can use the ftp command from the shell in all cases successfully, so it's no a firewall or connectivity issue. I always get NULL as a result, and no errors, if the domain name is valid and serving FTP. I d...

Testing for security vulnerabilities in web applications: Best practices?

Hi y'all I'm developing a web application. Like, a proper one, I've used things like Joomla in the past to make awesome stuff but have now finally got my hands dirty with PHP, MySQL and CodeIgniter. When you're making serious web apps that'll handle large amounts of data, what precautions should I take against my data inputs to fully s...

Problem (un-)greedy RegExp

Consider the following Strings: 1: cccbbb 2: cccaaabbb I would like to end up with are matches like this: 1: Array ( [1] => [2] => bbb ) 2: Array ( [1] => aaa [2] => bbb ) How can I match both in one RegExp? Here's my try: #(aaa)?(.*)$# I have tried many variants of greedy and ungreedy modifications but it doe...

ckeditor + media wiki

hey guys i searched alot but didnt find a tutorial on how to install ckeditor for media wiki i asked there but no one answered , im sure , i should ask here , but as you are professionals maybe know it thanks in advance ...

ASIHTTPRequest File Upload and PHP

I am using the following code (with ASIHTTPRequest) to attempt to upload php files from my iPhone to my LAN MAMP server running on my Macbook Pro. My objective-c and my php seem to be in line, but the files are not uploading. OBJECTIVE-C CODE NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMas...

PHP: How can I check for errors during a mysqli commit?

Hello, I am inserting a lot of records using mysqli commit statement, using this code from http://www.php.net/manual/en/mysqli.commit.php#88857. I then check affected rows using: $mysqli->affected_rows but even though all records have been inserted, I get zero affected rows. How can I check when commit failed and retrieve the error? Tha...

How does the .htaccess mod_rewrite for my Site: http://bit.ly/2Ocf3B looks like, to have SEO friendly urls?

I'm trying to optimize my site to make it SEO and user-friendly, I have several problems to set the right mod_rewrite for the urls and need help for this, I'm new to it, so it's way beyong my knowledge for the moment. http://bit.ly/2Ocf3B , the site should look like this: www.domain.me/category/subcategory . thanks ...

Does my fat-client application belong in the MVC pattern?

The web-based application I’m currently working on is growing arms and legs! It’s basically an administration system which helps users to keep track of bookings, user accounts, invoicing etc. It can also be accessed via a couple of different websites using a fairly crude API. The fat-client design loosely follows the MVC pattern (or per...

Extending classes in PHP

When extending classes in Java, class name ambiguity is avoided by the usage of qualified package names in the import statements. For example: Say I want my controller to extend Spring's MultiActionController - I'll import the same from the standard Spring package. This also prevents me from extending Mike's or Perry's MultiActionContr...

Parsing of badly formated HTML in PHP

In my code I convert some styled xls document to html using openoffice. I then parse the tables using xml_parser_create. The problem is that openoffice creates oldschool html with unclosed <BR> and <HR> tags, it doesn't create doctypes and don't quote attributes <TABLE WIDTH=4>. The php parsers I know off don't like this, and yield xml ...

Record User Actions Using PHP and Javascript

I am developing an online learning system (PHP, MySQL and Javascript). I would like to track what pages and how long each users spent on each page. Ideally, I would like to record this in a MySQL database. My question is 2 fold: 1. What kind of fields would I include in my db table to record multiple pages accessed? 2. Is this problem be...

Search block does not work in Drupal.

Hey, I just uploaded a test site on the following location : www.betterclassofleaders.co.cc/whackk I am using a customised search block (customised through search-theme-form.tpl.php) but it does not work. If you type in a search term and hit Enter it will go to the search result page but without actually performing the search. Searchin...

fpassthru problem in PHP5

My web host has a "process killer" which terminates any process running longer than about 5 minutes, so my download script can't run for that long. I thought I'd use fread-print for a few seconds, just to catch if the user aborts the download initially and then use fpassthru to to dump the rest of the file. ob_end_clean(); $file = fope...