This example is from php.net:
<?php
function Test()
{
static $a = 0;
echo $a;
$a++;
}
?>
And this is my code:
function getNextQuestionID()
{
static $idx = 0;
return $idx++;
}
And I use it in JavaScript:
'quizID=' + "<?php echo getNextQuestionID(); ?>"
Returns 0 everytime. Why?
...
EDITED (after 1st answer):
Can anyone help by pointing to some good references for the creation and presentation of a 3D environment (a real room) on a website.
Ideally it will not involve too much expense or too high a learning curve as this is a one off requirement for a small project.
...
I'm trying to create and retrieve a BLOB in a MySQL table via Kohana's ORM library.
The code looks something like:
$attachment = new Attachment_Model();
$attachment->name = $info['FileName'];
$attachment->size = strlen($info['Data']);
$attachment->data = $info['Data'];
$attachment->mime_type = $info['content-type'];
$attachment->save()...
The existing site has it own "users" table in a database. I'm wondering how to integrate PHPList with the existing site so that a user can check the newsletter during registration. I installed phplist thru cpanel.
Any help is greatly appreciated.
...
I am developing a CMS where the clients will need to upload files larger than 2mb - up to 10mb at least. I have changed the details in the php.ini file and I cannot see anywhere else that the problem might be. Any help?
Cheers
...
What's the best/easiest to integrate templating system for PHP, and what are the benefits of using one?
I currently don't use one at all, and am thinking that it might help to seperate content from presentation a little more.
...
I know mime_content_type() is deprecated, but it seemed to me the alternative is worse at the moment. Finfo seems to require adding files and changing ini directions on windows; I don't want to require this for the script I am making.
I need to find the mimetype of files, but when calling mime_content_type($filename) on windows it fails...
Is it possible to integrate my PHP web-based ecommerce application with Quickbook Online Edition?
When I make a sale on my web site, I would like to be able to make the corresponding journal entry in my accounting books.
Note, I'm referring to Quickbook Online Edition, not the desktop software.
...
echo "<td><a href='delete.php?id=$row[id]&&category=$a' onclick='return confirm(\'are you sure you wish to delete this record\');'>delete</a></td>";
Above is the code i am trying to use. Every time it does nothing and i cannot see how i can use 'proper' javascript methods. Any help would, as usual, be much appreciated.
Cheers guys!
...
Recent versions of PHP have a cache of filenames for knowing the real path of files, and require_once() and include_once() can take advantage of it.
There's a value you can set in your php.ini to set the size of the cache, but I have no idea how to tell what the size should be. The default value is 16k, but I see no way of telling how ...
I have implemented what I thought was a pretty decent representation of MVC in several web applications but since having joined crackoverflow, I'm finding that perhaps my initial definitions were a bit simplistic and thus I'd really like some clarification on the differences between the Data Access Layer and the Model or Domain Layer of ...
Hoi!
I have a form I wish to submit, but I need to add the PHPSESSID, because some clients allow no cookies.
There are several javascript functions on my page which displays a list of users (search, sort, open details), the page is generated by PHP.
Now I am looking for an elegant way to have the PHPSESSID included in every submit of ...
I'm using the PHP function imagettftext() to convert text into a GIF image. The text I am converting has Unicode characters including Japanese. Everything works fine on my local machine (Ubuntu 7.10), but on my webhost server, the Japanese characters are mangled. What could be causing the difference? Everything should be encoded as UTF-8...
I've found a few samples online but I'd like to get feedback from people who use PHP daily as to potential security or performance considerations and their solutions.
Note that I am only interested in uploading a single file at a time.
Ideally no browser plugin would be required (Flash/Java), although it would be interesting to know th...
Is there an efficient way of detecting if a jpeg file is corrupted?
Background info:
solutions needs to work from within a php script
the jpeg files are on disk
manual checking is no option (user uploaded data)
I know that imagecreatefromjpeg(string $filename); can do it. But it is quite slow at doing so.
Does anybody know a...
In asp.net, you can retrieve MULTIPLE datatables from a single call to the database. Can you do the same thing in php?
Example:
$sql ="select * from t1; select * from t2;";
$result = SomeQueryFunc($sql);
print_r($result[0]); // dump results for t1
print_r($result[1]); // dump results for t2
Can you do something like this?
...
Hi,
I have a set of Word documents which I want to publish using a PHP tool I've written. I copy and paste the Word documents into a text box and then save them into MySQL using the PHP program. The problem I Have arises from all the non-standard characters that Word documents have, like curly quotes and ellipses ("..."). What I do at t...
I'm looking for best practices for performing strict (whitelist) validation/filtering of user-submitted HTML.
Main purpose is to filter out XSS and similar nasties that may be entered via web forms. Secondary purpose is to limit breakage of HTML content entered by non-technical users e.g. via WYSIWYG editor that has an HTML view.
I'm ...
I'm starting a new project and I'm looking for a nice, light MVC framewok for PHP.
I'll use PDO for database abstraction and jQuery as UI framework.
...
Has anyone used Pear: Spreadsheet_Excel_Writer?
The Formatting Tutorial lists a script similar to what I'm working with: (trimmed down)
<?php
require_once 'Spreadsheet/Excel/Writer.php';
$workbook = new Spreadsheet_Excel_Writer();
$worksheet =& $workbook->addWorksheet();
$worksheet->write(0, 0, "Quarterly Profits for Dotcom.Com");
$w...