php

Using Pygments with PHP (Python in PHP)

Is it possible to use Python (specifically Pygments) with PHP? Currently, I have a phpBB forum that I'm developing for and JS Syntax Highlighters just haven't been working for me. There's already a GeSHI mod, but I want to develop something myself just for experience. Also, would there be performance issues? ...

PHP recursive directory listing - directories ONLY

I am working on a file manager project and can't seem to get my head around doing a recursive directory listing where I only get the directories. Everything I've tried either leaves off empty sub-directories or won't work when I try to parse it into the return structure to my jQuery tree. I've tried using an array, and the recursive ...

PHP - How to make a function return both 0 and true?

so.. is this possible? because I see some native php functions can do that for example strpos() can return 0 which can apparently be true ...

magento sales_order_place_after observer

I'm trying to write an observer that will export order data when an order is placed. I haven't written any modules before. Basing my implementation on this article: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method so far I'm just trying to...

Is PHP Serialized Object Data Clean For Mysql Injection?

Do I need to escape my object data if I'm serializing for mysql injection? ie: class Object { public $description; } $obj = new Object(); $obj->description = mysql_real_escape_string("this is my crazy string with lot's of bad // characters"); $data = serialize($obj); // <-- $data will be stored in DB or will this suffice: class...

how can i get ORM to work with 2 separate databases without foriegn keys defined in the tables?

I'm not even sure if this is possible. I am using Kohana framework(ver 2.3). I have 2 separate databases. One called 'employees' and another called 'tracker'. The databases are used in 2 different websites. I want to eliminate a table in the tracker database called 'csr', which contains identical employee data, and link the tracker to th...

session variables not carrying over from http://www.xxxx.com to http://xxxx.com

I was brought aware of this issue by some users on my website. A user many enter into their browser http://xxxx.com and then login. Then they may click on a link that brings them to http://www.xxxx.com it asks them to login again! Is this a known issue that anyone has encountered before? I tried googling it but im not sure if im using th...

Count occourances by hour in PHP

I have a script that polls a MySQL database (Nagios, specifically) for the date/time of events. I want to count how many events occur in each hour based upon all of the data my script returns. Here is what the results look like: (each on their own line) 2010-03-01 03:20:26 2010-02-28 19:07:26 2010-02-28 00:50:37 2010-02-27 17:07:35 ...

Inserting a custom Postgres datatype with PHP

CREATE TYPE mpaa_rating AS ENUM ( 'G', 'PG', 'PG-13' ); CREATE TABLE film ( film_id integer DEFAULT nextval('film_film_id_seq'::regclass) NOT NULL, rating mpaa_rating DEFAULT 'G'::mpaa_rating ); I've tried the following: pg_insert($dbconn, "film", new array("rating" => "PG")); pg_insert($dbconn, "film", new array...

jQuery ready function being called twice in a dialog

I am building a jQuery dialog with tabs in a PHP script. The script uses the 'include' directive inside of a loop, iterating over the tabs and including the other scripts. Each of the included files has the data for the tab and a <script> tag with a jQuery document.ready() function in it. Without the loop, it essentially does this: <...

Breaking a parent function from within a child function (PHP Preferrably)

I was challenged how to break or end execution of a parent function without modifying the code of the parent, using PHP I cannot figure out any solution, other than die(); in the child, which would end all execution, and so anything after the parent function call would end. Any ideas? code example: function victim() { echo "I shou...

security precautions to take when running multiple sub-sites on the same main site

I have shared hosting, and within my own user space I run three different .com domains. One serves as the actual hosting plan master domain, and the other are subs via URL redirects and domain pointing. One of those subs is a Wordpress blog, and I'm concerned about the ability of an attacker to use security holes in Wordpress to access ...

How to display images when a link is clicked using JQuery, PHP & MySQL?

Lets say a member is displaying 10 images by default but a link will display the rest of the users images by having them slide down when a user clicks a link. So my question basically is I want to be able to display all the users images buy having them slide down when a user clicks on a link <a>. How would I be able to tackle this prob...

What type of documentation does WordPress code follow?

I am trying to begin using some sort of standard for documenting my PHP code. Most of my code is in the form of WordPress plugins, some are getting quite complex, and I need to document it. So my question is simple, what system does WordPress use to document their code? ...

PHP - Removing <?php ?> tags from a string

What's the best way to remove these tags from a string, to prepare it for being passed to eval() ? for eg. the string can be something like this: <?php echo 'hello world'; ?> Hello Again <?php echo 'Bye'; ?> Obviously str_replace won't work because the two php tags in the middle need to be there (the the 1st and the last n...

Why is my insert not working in php?

I have an insert statement I am querying to the DB. $notes_sql = 'INSERT into notes SET order_id = "'.$_GET['order_id'].'", date_added = "'.$date_added.'", note_message = "'.$_SESSION['note_message'].'"'; $notes_result = $conn->query($notes_sql) or die(mysqli_error($conn)); I know the sql sta...

What is equivalent of RequestDispatcher#forward() Of Java in PHP?

Hello, RequestDispatcher basically dispatches a request to some other resource i.e it doesn't do a redirect but simply forwards the page to some page(resource). Thus browser's history etc is not updated and the parameters that are available in request are still available on another page since we are not creating a new request using redi...

Get last two ids from table based on condition

I was wanting to know how I get the last two ids from the table based on certain conditions for example, if today is 1st July, I want to get the id of record for today and then the id of the record before this. Please note that the id for the previous record might be different, as this is sorted by date, so previous_id = current_id - 1...

Creating and using multi-dimensional array in php

$breakfast = array( 'rest_id' => $rest_id , 'type' => 'Breakfast' , 'value' => $bprice ); $lunch = array( 'rest_id' => $rest_id , ...

form trying to open php file

Hi, I'm new to php and I have the following form in my html file: <form id="loginForm" action="login.php" method="post"> <label for="username">Username:</label> <div> <input type="text" name="username" maxlength="255"/> </div> <label for="password">Password:</label> <div> <input type="password" name="...