php5

Specifying Cell Format in CSV File

I am generating a csv file from a PHP array. It opens just fine in Excel and OpenOffice Calc, however the data in one of the column are zip codes. Excel makes the cell formats of the column number general by default. This results in the leading 0 getting dropped in zip codes. Is there any way I can specify the cell formats within the...

What's wrong with my MySql query ?!

This is a query I am doing with mysql using PHP This is the query line <?php $query = "SELECT * FROM node WHERE type = 'student_report' AND uid = '{$uid}' LIMIT 1 ORDER BY created DESC"; ?> I get the following error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right synt...

Why am I returning empty records when querying in mysql with php?

I created the following script to query a table and return the first 30 results. The query returns 30 results, but they do not have any text or information. Why would this be? The table stores Vietnamese characters. The database is mysql4. Here's the page: http://saomaidanang.com/recentposts.php Here's the code: <?php header( 'Co...

Error : execution time for the action exceeded .. secs. In PHP only on Linux.

Hi I am facing an Error : execution time for the action exceeded .. secs. In PHP. I am using set_time_limit(0); and it is working fine on windows. but it is not working on linux. what might be the reason? Thanks & Regards Rahul ...

Writing to static classes in PHP

Assuming I have a Config class that I use to access the config vars from everywhere (Config::X). Is it possible to implement a function that can be called from outside the class that adds and/or modifies properties? Something like this is what I'm thinking of: class Config { const myVar = 'blah'; public static function write( ...

PHP Launch script after background process completes?

I am converting a PDF with PDF2SWF and Indexing with XPDF.. with exec.. only this requires the execution time to be really high. Is it possible to run it as background process and then launch a script when it is done converting? ...

Way to store variable value is different than the way to store variable address(location).

Hello, Is it true that the syntax for (assign of variable value) is different than the syntax for (assign of address) in PHP. Like: If we want to store variable value to another variable then we can do it like this: $b=2; $a=$b; print $a; print $b; // output is 22 But if we want to store variable address to another variable then we ...

[php] Reading or altering $_SESSION data outside of the current session context

Usage case: In order to handle acces rights for a web application without having to check them each time a page is displayed, I came up with this sheme: When an administrative user grants or removes access rights to an application user, check if there is a session currently associated with him. Case being, alter session data. Does php5...

Disable native Soap class in PHP5 and use nuSoap?

I've spent the last week developing code to connect to a Web Service using the nuSoap library. I just deployed the code to production, but immediately started getting error's that I hadn't seen before. I traced the problem back to a line of code that is trying to instantiate a new soapclient object. It turns out that both libraries have ...

An array stored in MySQL is not recognized as a value

I am trying to store a json encoded array into a MySQL field. The stored array is in the form: ['value1', 'value2', 'value3'] Then I try and run a query like: SELECT * FROM mytable WHERE arrayfield it returns no results. The arrayfield is either blank or contains an array, so I am trying to get the records that only contain an array ...

PHP include file problem

Hi there again. I have a problem with including files on remote server (but on my local Windows PHP+Apache configuration it works fine...). Problem occurs when I try to include file from included file like this: Contents of index.php: <?php include("Dir1/File1.php"); ?> Contents of Dir1/File1.php: <?php include("File2.php"); inc...

How can I replace ?myuser=number with an empty string in PHP

How can I replace a string containing a lot of ?myuser=12122 ?myuser=5457 ... with empty string so that it doesn't show ?myuser=number inside the string? I think I should use regex? ...

PHP: ordered directory listing

How to list files in a directory in "last modified date" order? (PHP5 on Linux) ...

How does Zend_Db_Table_Select work?

I'm trying to figure out how to use Zend_Db_Table_Abstract correctly. I want to return just the name column from my query. Can you please explain what's wrong with the following code? class Model_DbTable_Foo extends Zend_Db_Table_Abstract { protected $_name = 'foo'; public function getFooById($id) { $select = $this->select(tr...

Using a singleton database class in functions and multiple scripts(PHP) - best use methods

I have a singleton db connection which I get with: $dbConnect = myDatabase::getInstance(); which is easy enough. My question is what is the least rhetorical and legitimate way of using this connection in functions and classes? It seems silly to have to declare the variable global, pass it into every single function, and/or recrea...

PHP 5 functioning returning an array- interaction without assignment?

I'm wondering if this kind of thing will ever be possible in PHP (and whether it already is and I'm just missing something...) <?php function test() { return array( 'id'=>10, 'name'=>'John' ); } echo 'Your name is: '.test()['name']; ?> I'd really like to be able to use returned arrays directly instead of first assigning them ...

PDO Parameterized Query - Reuse named placeholders?

In essence, I have a value that I have to call a couple times in my SQL query. Thus, is it possible to reuse the same named placeholder in the statement e.g. SELECT :Param FROM Table WHERE Column = :Param, then simply bindValue(":Param"), and have the value be there for both :Params? ...

php syntax confusion accessing database result

I am trying to do the following: <?php foreach($sqlResult as $row): ?> <tr> <?php foreach($formdata['columns'] as $column): ?> <td><?php echo $row->$column['name']; ?></td> <?php endforeach; ?> </tr> <?php endforeach; ?> This does not work. $row is returned by my mysql query, it has the following :...

The best open sources scripts for city-guide sites

I am looking for the best open source scripts for city-guide sites. Any suggestions? ...

PHP , What is the difference between fopen r+ and r ! does it matter if i used r+ when not intending to write

when I use fopen function , why don't I use r+ always , even when I'm not going to write any thing ... is there a reason for separating writing/reading process from only reading .. like , the file is locked for reading when I use r+ , because i might write new data into it or something ... another question : in php manual a+ : Ope...