php

Apache serves blank page

Hi I have created one sample php script to upload excel sheets of very bigger sizes. Also the process happening with each records given in the excel sheets is bit complex. To allow bigger sizes, I have added necessary php ini values in the apache configuration file to override the actual php ini values. The problem is, once i upload th...

Searching through a string trying to find ' in PHP

I am using tinyMCE and, rather annoyingly, it replaces all of my apostrophes with their HTML numeric equivalent. Now most of the time this isn't a problem but for some reason I am having a problem storing the apostrophe replacement. So i have to search through the string and replace them all. Any help would be much appreciated ...

Session not saving when moving from ssl to non-ssl

I have a login screen that I force to be ssl, so like this: https://www.foobar.com/login then after they login, they get moved to the homepage: https://www.foobar.com/dashbaord However, I want to move people off of SSL once logged in (to save CPU), so just after checking that they are in fact logged in on https://www.foobar.com/dashbaor...

PHP Change Array Keys

Array(0=> blabla 1 => blabla 2 => blblll) etc.. Is there a way to change all the numeric keys to "Name" without looping through the array (so a php function)? ...

Is it good practice to initialize the elements in an associative array in php?

I'm finding myself doing a lot of things with associative arrays in PHP. I was doing this: foreach ($item as $key=>$value) { if ($arr[$key] == null) { $arr[$key] = 0; } $arr[$key] += $other_arr[$value]; } But then I realised that it works fine if I exclude the line that initializes $arr[$key], presumably since it...

showing related data from mysql in ajax

Hello, I have the following code, which works fine: echo '<div id="Result">Content goes here</div>'; echo "<h1>Table: {$table}</h1>"; echo "<table border='1'><tr>"; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; // printing table...

How to Pass Variables Into PHP Ajax Handler Script?

Hello, I have a small ajax php application, which outputs data from a mysql db into a table. The rows are links, which when clicked will call an ajax function, which in turn will call another php file, which displays a different query from the same database in a layer without reloading the page. I would like to know how to synchronize ...

Defend PHP; convince me it isn't horrible

I made a tongue-in-cheek comment in another question thread calling PHP a terrible language and it got down-voted like crazy. Apparently there are lots of people here who love PHP. So I'm genuinely curious. What am I missing? What makes PHP a good language? Here are my reasons for disliking it: PHP has inconsistent naming of built-in...

Considering ATK Framework

Has anybody used the ATK Framework? It is claimed to be geared toward developing apps for business use. Manipulating data, knowledge bases, etc... This is what I primarily develop (on the side-for my own use). The site hasn't given me a great overview of why it may be better than other frameworks. What are your thoughts / experienc...

mysql php : switching between mysql databases is slow

In my php script which connects to mysql, I have to query 2 databases in the same script to get different information. More specifically Faxarchives in one database and Faxusers in the other. In my code I query faxusers and then foreach user, I query Faxarchives to get the user history. I might do something like: function getUser...

Connect to a MySQL server over SSH in PHP

I'd like to establish an ssh tunnel over ssh to my mysql server. Ideally I'd return a mysqli db pointer just like I was connecting directly. I'm on a shared host that doesn't have the SSH2 libraries but I might be able to get them installed locally using PECL. If there's a way that uses native commands that would be great. I was thin...

PHP Script to check when a link was last modified

Is there a basic php method that accepts a URL and retrieves the date last modified from the header? It would seem like something php can do, but I'm not sure which object to check. Thanks ...

regex (in PHP) to match & that aren't HTML entities

Here's the goal: to replace all standalone ampersands with &amp; but NOT replace those that are already part of an HTML entity such as &nbsp;. I think I need a regular expression for PHP (preferably for preg_ functions) that will match only standalone ampersands. I just don't know how to do that with preg_replace. ...

Decode gzipped web page retrieved via cURL in PHP

I'm retrieving a gzipped web page via curl, but when I output the retrieved content to the browser I just get the raw gzipped data. How can I decode the data in PHP? One method I found was to write the content to a tmp file and then ... $f = gzopen($filename,"r"); $content = gzread($filename,250000); gzclose($f); .... but man, there'...

How to check file types of uploaded files in PHP?

On the PHP website, the only real checking they suggest is using is_uploaded_file() or move_uploaded_file(), here. Of course you usually don't want user's uploading any type of time, for a variety of reasons. Because of this, I have often used some "strict" mime type checking. Of course this is very flawed because often mime types are w...

How to call ASP.NET .dll file from a PHP script?

Do you know how can I call an ASP.NET .dll file from a PHP scritp? Thanks! ...

What's the best way to develop local using PHP and Visual Studio?

I am taking my first foray into PHP programming and need to configure the environment for the first time. Can I use PHP with the built in VS web server or do I need to (and I hope not) use IIS locally? In addition, any pointers on pitfalls to be avoided would be great. Many thanks. Update: I should have made the question more explicit...

is filter_var sufficient to sanitise integer input for php-based mysql queries?

I've never liked wrapping the mysql_real_escape_string function around input I expect to be integer for inclusion in a mysql query. Recently I came across the filter_var function. Nice! I'm currently using the code: if (isset($idUserIN) && filter_var($idUserIN, FILTER_VALIDATE_INT) && 0 < filter_var($idUserIN, FILTER_...

PHP open another webpage with POST data

I'm new to PHP and I'm trying to do something that may be bad practise and may well be impossible. I'm basically just hacking something together to test my knowledge and see what PHP can do. I have one webpage with a form that collects data. That is submited to a PHP script that does a bunch of processing - but doesn't actually display ...

problem with PHP reading CSV files

I'm trying to read data from a.csv file to ouput it on a webpage as text. It's the first time I'm doing this and I've run into a nasty little problem. My .csv file(which gets openened by Excel by default), has multiple rows and I read the entire thing as one long string. like this: $contents = file_get_contents("files/data.csv"); I...