php

mysqli->error: Is it for the last query only, or for the last error from the query group?

Hi All, I am new to mysqli, and trying to confirm that if I so something like the below, the errno will be set to the last error, if any, and not the error of the last query. Is this a decent practice or should I be checking for the error in between every query? Thanks! $mysqli->autocommit(FALSE); $mysqli->query("INSERT INTO ........

Algorithm for generating a random number

I'm looking to generate a random number and issue it to a table in a database for a particular user_id. The catch is, the same number can't be used twice. There's a million ways to do this, but I'm hoping someone very keen on algorithms has a clever way of solving the problem in an elegant solution in that the following criteria is met: ...

Is it possible to "symlink" a function in PHP easily - or alias the name to something else?

For example, I hate typing things like: $x = mysql_escape_string(stripslashes($_GET['x'])); Is there a way to alias those two functions in init.php or something without writing a separate function that takes one argument and returns that argument with those functions applied to it? My C/C++ is not very good, but I think this is sort ...

PHP Shipping Calculator

Does anyone know of a freeware shipping calculator for PHP? I do not want anything too fancy, and it can be compatible with any of the major US domestic shipping services. If anyone knows of one that is a plugin for CodeIgniter that would be nice. Travis ...

Postage Calculator for PHP

Could anyone point me in the right direction for a shipping calculator? I would like something simple and I don't want to sign up for too much stuff. EDIT: I do not want to deal with all the registering and stuff the API would require... I think I may just try to make one using the zone charts USPS provides. ...

PHP - call function in object with set_error_handler()

Hi Stackers I am trying to use this in my page class. I only just started using objects in PHP so I'm still a little clueless (but learning as much as I can). This is in my page() function (so called when there is a new instance of page) set_error_handler('$this->appendError'); This is causing an error Warning: set_error_handler() e...

How do detect that transaction has already been started?

I am using Zend_Db to insert some data inside a transaction. My function starts a transaction and then calls another method that also attempts to start a transaction and of course fails(I am using MySQL5). So, the question is - how do I detect that transaction has already been started? Here is a sample bit of code: try { ...

How do I make a PHP script talk?

I am trying to make a PHP script talk to the user. Do I need flash? ...

Can you code a class function outside of a class in PHP?

In C++, I code this way: //foo.h class cBar { void foobar(); } //foo.cpp void cBar::foobar() { //Code } I tried to do this on PHP but the parser would complain. PHP's documentation also doesn't help. Can this be done in PHP? ...

Why does my XAMPP installation auto redirect to http://localhost/xampp?

I installed XAMPP on my computer which is running Windows XP SP3. Installation was successful. I made a PHP file (index.php) and placed it in my htdoc folder and then tried to open http://localhost/index.php in my browser. It is automatically going to http://localhost/xampp instead. It is not opening index.php. What have I done wrong?...

making a blog using php

I am new to php and wanted to make a blog using php where every one can see the contents posted in the site but another administrator page should be there which can edit, add or delete posts How can i code a page like that? What are the logics required? ...

How to include output of PHP script in Python driven Plone site?

I need to have the output of a PHP snippet in a Plone site. It was delivered to be a small library that has a display() function, in PHP, that outputs a line of text. But I need to put it in a Plone site. Do you have any recommendations? I was thinking a long the lines of having a display.php that just runs display() and from the Plone ...

Encrypting data in Cocoa, decoding in PHP (and vice versa)

The situation I'm trying to solve: in my Cocoa app, I need to encrypt a string with a symmetric cipher, POST it to PHP, and have that script decode the data. The process needs to work in reverse for returning an answer (PHP encodes, Cocoa decodes). I'm missing something because even though I can get both the key and initialization vect...

Checking for file-extensions in PHP with Regular expressions

I'm reading all the files in a single directory and I want to filter on JPG,JPEG,GIF and PNG. Both capital and small letters. Those are the only files to be accepted. I am currently using this: $testPics = takeFiles($picsDir, "([^\s]+(?=\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF))\.\2)"); and the function takeFiles looks like this: funct...

Highlight the difference between two strings in PHP

Hi, What is the easiest way to highlight the difference between two strings in PHP? I'm thinking along the lines of the Stack Overflow edit history page, where new text is in green and removed text is in red. If there are any pre-written functions or classes available, that would be ideal. Thanks in advance. ...

What tools/languages do you use for PHP web application deployment ?

For my web application running on LAMP, I need to be able to deploy database migrations and code changes on multiple servers and be able to test deployment afterwards, all of this automatically done by scripts. Currently I'm torn between using directly my build tool (Phing) with some special deployment/test tasks, or shell scripts, or a...

What is the best way to get the errors from a production site in PHP?

For most production sites, you want to know when there has been an error as soon as possible. My question is how best to get this information. Usually, it's probably best to get the errors in an email as I'm not going to sit every day and watch error logs until there is an error--this would be impossible since I have 20 or more producti...

What is included in each error level in PHP

I'm basically wondering what is included in each error level, as found here in PHP. Example, where does an unset variable or key fall? Or where does a parse fall? I can't seem to find any documentation on the PHP website or general internet regarding this. Edit: I'm looking for a list of what error causes what error level/type or the ot...

Rss question, replacing items

Hi, i have a rss source: http://feedity.com/rss.aspx/mr1-kossuth-hu/VVdXUlY <item> <title>2008. november 23.</title> <link>http://www.mr1-kossuth.hu/m3u/0039c36f_3003051.m3u&lt;/link&gt; <description>........</description> <pubDate>Wed, 26 Nov 2008 00:00:00 GMT</pubDate> </item> from this, i want to creat...

How do you determine if a variable contains a file pointer in PHP?

Exactly as the question states: How can you check if a variable in PHP contains a file pointer? Some like is_string() or is_object(). ...