php

What's the fastest way to populate an array with numbers in PHP?

What's the fastest way to populate an array with the numbers 1-100 in PHP? I want to avoid doing something like this: $numbers = ''; for($var i = 0; i <= 100; $i++) { $numbers = $i . ','; } $numberArray = $numbers.split(','); It seems long and tedious, is there a faster way? ...

Subfolder for website on Mac OS X

I would like to run a local PHP (5.3) website on Mac OS X 10.6. I have PHP configured properly and can access a website using http://mymac.local/~me/index.html. I have this folder structure: ~me/Sites/index.html which points to http://mymac.local/~me/index.html ~me/Sites/mysite/home.html which doesn't work If I try http://mymac.loca...

send Gmail from php form

I have a project to setup an anonymous feedback form to our website. I wanted to have a go at it with php the general idea is that I would have a password field (give out to our employees) a field for the feed back and a button to Ive seen this code snippet <?php $to = "[email protected]"; $subject = "Hi!"; $body = "Hi,\n\nHow ar...

Convert PDF to JPG automatically on upload in Drupal

Hiya, I was wondering if anyone knows how to automatically convert PDF's to JPGs in Drupal when a user uploads, i'm able to create a script to do the actual conversion but my dilema is being able to catch the file on upload and the process it. (or if there is a script/module that already does it it would be even better!). Thanks in adv...

regexp split string by commas and spaces, but ignore the inside quotes and parentheses

I need split string by commas and spaces, but ignore the inside quotes, single quotes and parentheses $str = "Questions, \"Quote\",'single quote','comma,inside' (inside parentheses) space #specialchar"; so that the resultant array will have [0]Questions [1]Quote [2]single quote [3]comma,inside [4]inside parentheses [5]space [6]#spec...

REGEXP to convert any 3 chars or less word to wordVVV

I am trying to convert any occurrence of a word with 3 chars or less to the same word with the string VVV attached to it. Example: for -> forVVV I am using none Latin chars (UTF8), hence the MB. What I have is: $pattern='\b[.{1,6}]\b'; $text=mb_ereg_replace($pattern,'\0VVV',$text,'me'); What am I missing? Here is a case study, see ...

Possible injection from date string Select query

Hi all. I have a problem wich is a little strange. My page contains a html link which refreshes the page and calls a PHP variable. This variable appends a date string to the url string which is fed into a MySQL query, which grabs records matching this date. I think this is causing an injection as it sometimes deletes the user from the d...

MySQL query fails sometimes when using Internet Explorer

I am new to php and MySQL. I have a site where a user can choose a state and display hospitals in that state. It works well in FireFox for all states, but in IE, when I have state with a couple hundred hospitals, the screen flashes and I eventually get a message that the page cannot be displayed. For smaller states with a few hospital...

Update Personal Details PHP Script

I have a page that displays a user's current personal information and a handler that cycles through the form elements, filtering them through to the relevant mysql query. There are two tables, one that contains the master data, e.g. username, email, password hash, and one that has address data. However, the script doesn't work and I can...

How could I customize Zend_Tool to provide my own skeleton/template ?

Zend_Tool is nice, it generates a project with a given name & a given path. But after a while, i started to develop my own tools, like helpers, plugins, validators, etc... I put them all in library, which is ok (and recommanded). But, i would have to start my project with the same bootstrap file, including initialization of my plugins...

When I export files with php/html my session data resets

I have a web-based system built with user login data based on session variables. Sometimes when a user is logged in and tries to export tables to csv or xls the session data seems to wipe and the user is 'kicked out' of the system. This is the header code I'm using to serve the file. header("Pragma: public"); header("Expires: ...

Retrieving data from MySQL in one SQL statement

Hi all, If I'm getting my data from Mysql like so: $result = $dbConnector->Query("SELECT * FROM branches, businesses WHERE branches.BusinessId = businesses.Id ORDER BY businesses.Name"); $resultNum = $dbConnector->GetNumRows($result); if($resultNum > 0) { for($i=0; $i < $resultNum; $i++) { $r...

Preventing class data inheritance (PHP)

Hello, I have a database abstraction layer that starts with a base class like so: class DB { function DB() { $this->host = "xxx"; $this->db = "xxx"; $this->user = "xx"; $this->pass = "xx"; $this->dbh = mysql_connect($this->host, $this->user, $this->pass); mysql_select_db($this->db); // etc } } class DB...

use preg_replace to replace character unless an escape character precedes

Hi all... i'm trying to do the following hope there's a reg_ex expert around to shed some light. I need to replace the character [ in my code and make it a {. But there is cases where the [ needs to remain a [ and not change. So the way i figured it is i need to use the preg_replace("[", "{", $string); function with a suitable regula...

Check if var exist before unsetting in PHP?

With error reporting on, or even for best practice, when unsetting a variable in PHP, should you check to see if it exist first (in this case it does not always exist) and the unset it, or just unset it? <?PHP if (isset($_SESSION['signup_errors'])){ unset($_SESSION['signup_errors']); } // OR unset($_SESSION['signup_errors']); ?> ...

Passing base64 encoded strings in URL

Is it safe to pass raw base64 encoded strings via GET parameters? ...

MultiLine textbox in html for php script

all, I wanted to create a multiline textbox but all the info i googled on it says that i can adjust the length but no the height How would i create a text box field that i could have a user type comments into for a php script? this is what I'm currently using <INPUT TYPE = "TEXT" > Bonus question: how do i disable enter in the tex...

php require function on linux server

does following this work on linux server? <? require 'foldername/header.php' ?> the above code is present in home.php. home.php is in folder foldername. ...

How to change PHP's eregi to preg_match

I need help, below is a small VERY basic regex to somewhat validate an email, I do realize it does not work the greatest but for my needs it is ok for now. It currently uses PHP's eregi function which php.net says is now a depreciated function and I should use preg_match instead, simply replacing erei with preg_match does not work, can...

can I easily recomplie PHP with all my current settings and enable SOAP with the new configuration?

I have PHP 5.1.6 running with a ton of mods and extensions enabled, is there a way to reconfigure the current settings as well as add SOAP to the mix? ...