php

Problem setting up local server

Hello! I'm trying to setup an Apache/PHP/Postgresql server locally on my machine. I tried to install everything manually (one thing at a time) and after I get everything up and running, whenever I try to run a script on my machine, I get a "What do you want to do with the *.php file?" dialog. NOTE: the dialog...

Where should assets go in a code igniter project?

I'm just starting with CI, and am not sure where things such as css, js, images should go. Outside the whole system folder seems ok, but that means everything is seperate. Inside mean s the filepaths are longer and I'm worried that it might mess things up. What's the official line on this? ...

PHP/PDO and SQL Server connection and i18n issues

In our web-app we use PHP5.2.6 + PDO to connect to a SQL Server 2005 database and store Russian texts. Database collation is Cyrillic_General_CI_AS, table collation is Cyrillic_General_CI_AS, column type is NVARCHAR(MAX). We tried connecting to a database using two following schemes, both causing different problems. PDO mssql: $dbh ...

Which PHP CMS has the best architecture?

In your opinion, which PHP CMS has the best architecture? I don't care about how easy its admin panel is to use, or how many CMS features it has. Right now, I'm after how good its code is (so, please, don't even mention Drupal or Wordpress /shudder). I want to know which ones have a good, solid, OOP codebase. Please provide as much de...

How to change envelope from address using PHP mail?

I am using PHP with Apache on Linux, with sendmail. I use the PHP mail() function. The email is sent, but the envelope has the Apache_user@localhostname in MAIL FROM (example [email protected]) and some remote mailservers reject this because the domain doesn't exist (obviously). Using PHP mail(), can I force change the envelope M...

In PHP, for what reasons can I not include a variable from external file?

If I have $var defined in Page1.php and in Page2.php I have //Page2.php include('Page1.php'); echo $var; For what reasons will it not print the value of $var to the screen? The files are in the same directory so paths shouldn't be the issue. I've checked the php.ini file and nothing really jumps out at me. Any ideas? Thanks ...

Mixed syntax for control structures generating syntax errors

I'm refactoring some PHP code and discovered that certain nested combinations of if () : and if () { generate syntax errors. Not that I would normally mix the two, but I like to do frequent syntax checks as I'm writing code and I kept getting a syntax error because of this. Example - generates syntax error: if ( $test == 1 ) :...

What's the proper use of php.ini's session.save_path?

I'm running PHP on Windows/IIS. My session variables don't seem to be preserved from page-to-page. This code //echos out the session variables in a nice format for inspection echo "<p><pre>"; print_r($_SESSION); echo "</pre></p>"; outputs blank values, like this Array ( [s_firstvar] => [s_var2] => ...

How do I install cURL on Windows?

Hi, I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/ to install & config apache get the PHP5 packages and get the CURL packages. I run the apache and run a PHP script. no problem. but when I run the php script with curl, it fails. It returns: Call to undefined fun...

Generating a unique ID in PHP

I'm trying to generate a unique ID in php in order to store user-uploaded content on a FS without conflicts. I'm using php, and at the moment this little snippet is responsible for generating the UID: $id = tempnam (".", ""); unlink($id); $id = substr($id, 2); This code is hideous: it creates a temporary file on the FS and deletes it...

PHP5: Specifying a datatype in method parameters

I have a function that looks like this class NSNode { function insertAfter(NSNode $node) { ... } } I'd like to be able to use that function to indicate that the node is being inserted at the start, therefore it is after nothing. The way I think about that is that null means "nothing", so I'd write my function call like...

PHP: mysql_connect() won't work via command line

Hi all, I have a script which calls mysql_connect() to connect to a MySQL DB. When I run the script in a browser, it works as expected. However, when I run it from a command line I recieve the error Call to undefined function mysql_connect() This seems completely paradoxical. Anyone have any ideas as how I can run it from the comman...

Does using global create any overhead?

Is it a problem if you use the global keyword on variables you don't end up using? Compare: function foo() { global $fu; global $bah; if (something()) { $fu->doSomething(); } else { $bah->doSomething(); } } function bar() { if (something()) { global $fu; $fu->doSomething(); } ...

electronic leave application database design

I am currently working on a leave application (which is a subset of my e-scheduler project) and I have my database design as follows: event (event_id, dtstart, dtend... *follows icalendar standard*) event_leave (event_id*, leave_type_id*, total_days) _leave_type (leave_type_id, name, max_carry_forward) _leave_allocation (leave_alloca...

Programmatically access currency exchange rates

I'm setting up an online ordering system but I'm in Australia and for international customers I'd like to show prices in US dollars or Euros so they don't have to make the mental effort to convert from Australian dollars. Does anyone know if I can pull up to date exchange rates off the net somewhere in an easy-to-parse format I can acce...

Can PHP PDO Statements accept the table name as parameter?

Why can't I pass the table name to a prepared PDO statement? $stmt = $dbh->prepare('SELECT * FROM :table WHERE 1'); if ($stmt->execute(array(':table' => 'users'))) { var_dump($stmt->fetchAll()); } Is there another safe way to insert a table name into a SQL query? With safe I mean that I don't want to do $sql = "SELECT * FROM $tab...

What is the best PHP lib/class to generate RSS/Atom

Hello, I have to produce RSS/Atom feed in various applications, and I want to know a good lib/class wich is able to produce both, and which already handle all common problems. For example the one I used for year does not put the right format for date, so my feed is not well handled by several aggregators. Thanks, Cédric Update : W...

How do I display the first letter as uppercase?

I have fname and lname in my database, and a name could be stored as JOHN DOE or john DOE or JoHN dOE, but ultimately I want to display it as John Doe fname being John and lname being Doe ...

Why are some PHP errors are not written in the PHP log?

Hello, On a server I have to take care of, errors from a vhost do not go to the standard PHP error log. In the php.ini we have log = /var/log/file and phpinfo() does not show any difference between the vhost and the whole server. But the callback function set up by set_error_handler() catches errors which are not in the php log. ...

Quickest way to implement a searchable, browsable image gallery - flickr integration?

I have a friend who is need of a web page. He does interior construction, and would like to have a gallery of his work. I'll probably go for a php host, and was thinking about the best way to implement the image gallery for him. I came up with: Use flickr to host the images. They can be tagged, added to sets, and I can use both the...